Programmatic API
Use emulators as libraries in your tests and scripts. There are two approaches: the emulate CLI package (which wraps all services) and the individual @emulators/* scoped packages.
CLI package
The emulate package provides a createEmulator helper that starts any service by name.
Generated secrets
When a GitHub App omits private_key, createEmulator generates an RSA-2048 PKCS#1 key for that emulator instance:
Generated keys remain stable across reset() calls and appear only in generatedSecrets. Explicitly configured keys are never returned there. A new createEmulator call generates a new key.
Vitest / Jest setup
createEmulator options
| Option | Default | Description |
|---|---|---|
service | (required) | Service name: 'vercel', 'github', 'google', 'slack', 'apple', 'microsoft', 'okta', 'aws', 'resend', 'stripe', 'mongoatlas', 'clerk', 'linear', or 'twilio' |
port | 4000 | Port for the HTTP server |
hostname | 127.0.0.1 | Listening address for built-in and custom emulators |
seed | none | Inline seed data (same shape as YAML config) |
baseUrl | none | Override the advertised base URL (used in OAuth redirects, webhook URLs, etc.). Per-service baseUrl in seed config takes highest priority, then this option, then the EMULATE_BASE_URL env var (supports {service} template), then PORTLESS_URL (supports {service}, automatically set by the portless CLI wrapper), then http://localhost:<port>. |
Use hostname: '0.0.0.0' to allow connections from containers or other machines, and baseUrl to advertise a URL reachable by those clients. This option also applies to custom definitions passed to createEmulator.
Instance methods
| Method | Description |
|---|---|
url | Base URL of the running server |
generatedSecrets | Readonly secrets generated while preparing seed data |
reset() | Wipe the store and replay seed data |
close() | Shut down the HTTP server, returns a Promise |
Scoped packages
Each emulator is published as its own @emulators/* package. Install only the ones you need:
Available packages
| Package | Service |
|---|---|
@emulators/vercel | Vercel API |
@emulators/github | GitHub API |
@emulators/google | Google OAuth, Gmail, Calendar, Drive |
@emulators/slack | Slack Web API, OAuth v2, webhooks |
@emulators/linear | Linear GraphQL API, OAuth, webhooks |
@emulators/twilio | Twilio Messaging, Verify, Voice, webhooks |
@emulators/apple | Apple Sign In / OIDC |
@emulators/microsoft | Microsoft Entra ID, Graph API |
@emulators/aws | AWS S3, SQS, IAM, STS |
@emulators/okta | Okta identity provider / OIDC |
@emulators/mongoatlas | MongoDB Atlas Admin API + Data API |
@emulators/resend | Resend email API |
@emulators/stripe | Stripe billing and payments API |
@emulators/clerk | Clerk Backend API and OAuth |
@emulators/core | Shared store, middleware, and utilities |
@emulators/adapter-next | Next.js App Router integration |
@emulators/adapter-nuxt | Nuxt server route integration |
Direct usage
Each scoped package exports its service plugin and seed helpers:
These are the same modules used internally by the CLI and the Next.js adapter or Nuxt adapter. See the framework integration pages for full examples of using scoped packages with createEmulateHandler.
Custom emulators
Custom definitions created with defineEmulator from emulate work in the CLI, in-process tests, and both framework adapters. The same definition provides typed state, HTTP handlers, reset, versioned snapshots, and optional inspection/persistence. See Custom emulators for the quickstart, API reference, and complete lifecycle semantics.