{"id":51337533,"url":"https://github.com/pjsny/clerk-emulator","last_synced_at":"2026-07-02T04:03:30.917Z","repository":{"id":365736022,"uuid":"1271295897","full_name":"pjsny/clerk-emulator","owner":"pjsny","description":"Local, offline emulator for Clerk auth (Backend API + FAPI). Real JWT signing, orgs, M2M tokens \u0026 webhooks. Works with @clerk/backend.","archived":false,"fork":false,"pushed_at":"2026-06-18T16:08:43.000Z","size":358,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-18T17:29:13.311Z","etag":null,"topics":["auth","authentication","clerk","clerk-emulator","emulator","fapi","jwt","local-development","mock","mock-server","oauth","testing","typescript","webhooks"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pjsny.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-16T14:20:16.000Z","updated_at":"2026-06-18T16:09:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pjsny/clerk-emulator","commit_stats":null,"previous_names":["pjsny/clerk-emulator"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pjsny/clerk-emulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjsny%2Fclerk-emulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjsny%2Fclerk-emulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjsny%2Fclerk-emulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjsny%2Fclerk-emulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pjsny","download_url":"https://codeload.github.com/pjsny/clerk-emulator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjsny%2Fclerk-emulator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35032146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth","authentication","clerk","clerk-emulator","emulator","fapi","jwt","local-development","mock","mock-server","oauth","testing","typescript","webhooks"],"created_at":"2026-07-02T04:03:30.402Z","updated_at":"2026-07-02T04:03:30.912Z","avatar_url":"https://github.com/pjsny.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/pjsny/clerk-emulator/main/assets/banner.png\" alt=\"clerk-emulator — local, offline, in-memory\" width=\"820\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/pjsny/clerk-emulator/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/pjsny/clerk-emulator/actions/workflows/ci.yml/badge.svg\" alt=\"CI\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/clerk-emulator\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/clerk-emulator\" alt=\"npm\" /\u003e\u003c/a\u003e\n  \u003ca href=\"./LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-Apache--2.0-blue.svg\" alt=\"License: Apache-2.0\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://socket.dev/npm/package/clerk-emulator\"\u003e\u003cimg src=\"https://socket.dev/api/badge/npm/package/clerk-emulator\" alt=\"Socket\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# clerk-emulator\n\nA local, offline emulator for [Clerk](https://clerk.com)'s Backend API (BAPI) and Frontend API (FAPI). Develop and test Clerk auth with no network, no cloud instance, and no rate limits — it signs real JWTs, so `@clerk/backend` and `clerk-js` work against it unmodified. Built on [Hono](https://hono.dev); state is in-memory and resets every run.\n\n## Install\n\n```bash\nnpm install --save-dev clerk-emulator\n```\n\n## Quick start\n\nRun the server:\n\n```bash\nnpx clerk-emulator\n# Backend API:  http://localhost:4000\n# Secret key:   sk_test_emulate\n```\n\nConfigure via env: `PORT`, `HOST`, `CLERK_SECRET_KEY`, `CLERK_MACHINE_KEY`. Add `--persist \u003cfile\u003e` (or `CLERK_PERSIST`) to keep state across restarts.\n\nPoint the backend SDK at it:\n\n```ts\nimport { createClerkClient } from \"@clerk/backend\";\n\nconst clerk = createClerkClient({ secretKey: \"sk_test_emulate\", apiUrl: \"http://localhost:4000\" });\nawait clerk.users.createUser({ emailAddress: [\"dev@example.com\"], password: \"supersecret123\" });\n```\n\nOr run it in-process for tests (no separate server):\n\n```ts\nimport { createServer, clerkPlugin } from \"clerk-emulator\";\n\nconst { app } = createServer(clerkPlugin, {\n  tokens: { sk_test_emulate: { login: \"admin\", id: 1, scopes: [] } },\n});\nconst res = await app.request(\"/v1/users\", { headers: { Authorization: \"Bearer sk_test_emulate\" } });\n```\n\n`app` is a [Hono](https://hono.dev) app — call `app.request(...)` in-memory, or `serve({ fetch: app.fetch, port })` (`@hono/node-server`) to bind a port.\n\nPoint the frontend (clerk-js) at it: set a **relative** `proxyUrl` so clerk-js sends Frontend API calls to a path your dev server forwards to the emulator (clerk-js forces `https` on _absolute_ proxy URLs, so it must be relative). Pin `clerkJSVersion` to skip the floating `@\u003cmajor\u003e` CDN redirect.\n\n```tsx\n// React entry\n\u003cClerkProvider publishableKey=\"pk_test_...\" proxyUrl=\"/__clerk\" clerkJSVersion=\"6.17.0\"\u003e\n```\n\n```ts\n// vite.config.ts — forward the proxy path to the emulator\nserver: {\n  proxy: {\n    \"/__clerk\": { target: \"http://localhost:4000\", changeOrigin: true, rewrite: (p) =\u003e p.replace(/^\\/__clerk/, \"\") },\n  },\n}\n```\n\nVanilla clerk-js is the same idea: `new Clerk(pk, { proxyUrl: \"/__clerk\" })`. See [`e2e/`](./e2e) for complete React, `@clerk/clerk-react`, and vanilla setups.\n\n## What's supported\n\n| Capability | Details |\n|---|---|\n| Users \u0026 email addresses | full CRUD, ban / lock, metadata, verify password |\n| Organizations | CRUD, memberships, invitations, domains |\n| Sessions \u0026 tokens | session CRUD, JWT minting, v1/v2 negotiation (`clerk-api-version` / `__clerk_api_version`) |\n| M2M tokens | create, verify, revoke |\n| OAuth 2.0 / OIDC | authorize, token, userinfo, JWKS |\n| Frontend API (FAPI) | sign-in, MFA (TOTP), sign-up |\n| Webhooks | Clerk-shaped resource events |\n| Testing tokens | `@clerk/testing` compatible — `POST /v1/testing_tokens`, `__clerk_testing_token` |\n| _Out of scope_ | social sign-in, passkeys, SAML / enterprise SSO, multi-session, billing, profile management |\n\n## Compatibility\n\nVerified in CI against:\n\n| Surface | SDK | Versions | Clerk core |\n|---|---|---|---|\n| Frontend (React) | `@clerk/react` | latest 6.x | Core 3 (Active) |\n| Frontend (React) | `@clerk/clerk-react` | latest 5.x | Core 2 (LTS) |\n| Frontend (vanilla) | `@clerk/clerk-js` | latest 5.x, 6.x | Core 2 (LTS), Core 3 |\n| Backend | `@clerk/backend` | latest 2.x, 3.x | Core 3 |\n| Runtime | Node.js | 20, 22, 24 | — |\n\nNot yet tested: `@clerk/backend` 0.x (Core 2 LTS, pre-Core-3 API) and `@clerk/nextjs`.\n\n## Tests\n\n```bash\nnpm test             # unit + integration (Node, against a real server)\ncd e2e \u0026\u0026 npm test   # browser e2e (Playwright, real clerk-js)\n```\n\n| Layer | Covers |\n|---|---|\n| Browser e2e — Playwright + clerk-js | sign-in (password / email-code / MFA-TOTP), sign-up, org listing |\n| SDK e2e — `@clerk/backend` over HTTP | admin lifecycle: users, organizations, memberships, invitations, domains, M2M |\n| HTTP integration — raw requests | OAuth / OIDC, webhooks, session-token v1/v2 negotiation |\n\nBrowser e2e and the backend SDK run across the version matrix in [Compatibility](#compatibility). See [`docs/testing.md`](./docs/testing.md) for Playwright/Cypress (`@clerk/testing`), backend-SDK, and in-process setups.\n\n## License \u0026 attribution\n\n[Apache-2.0](./LICENSE). The framework under `src/framework/` is adapted from [`vercel-labs/emulate`](https://github.com/vercel-labs/emulate) (Apache-2.0) with its HTTP layer swapped for Hono — see [`NOTICE`](./NOTICE).\n\n\"Clerk\" is a trademark of Clerk, Inc. This is an independent, unofficial tool — not affiliated with, endorsed by, or sponsored by Clerk, Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpjsny%2Fclerk-emulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpjsny%2Fclerk-emulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpjsny%2Fclerk-emulator/lists"}