@clerk/backend

The official JavaScript SDK for Clerk's Backend API and JWT session verification.

SDK
npm
v3.16.8
1,736stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
92/100Excellent
Development Activity100
Maintenance100
Community72
Maturity56
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture87
Code Quality88
Innovation85
Learning Curve78

@clerk/backend is Clerk’s server-side SDK for JavaScript and TypeScript runtimes, exposing a fully typed REST client for the Clerk Backend API alongside low-level utilities for verifying session tokens, handling webhooks, and authorizing requests. It underpins nearly every framework-specific Clerk package (Next.js, Express, Fastify, Remix, Hono, and more), so it ships the request-authentication primitives and resource clients that the rest of the Clerk JavaScript ecosystem builds on top of.

The package targets any V8-isolate or Node.js runtime, offering both edge- and Node-specific crypto implementations so the same authentication logic works in serverless middleware, edge functions, and traditional servers alike. Typed API classes cover users, organizations, sessions, sign-in tokens, webhooks, machine-to-machine tokens, and billing, giving backend code a single consistent client for everything the Clerk dashboard manages.

What You Get

  • A fully typed REST client covering Users, Organizations, Sessions, Webhooks, Machine-to-Machine tokens, Billing, and other Clerk Backend API resources
  • authenticateRequest/token verification utilities for validating Clerk session JWTs without a round trip to the API
  • Dual runtime crypto implementations (Node and edge/browser) selected automatically via package exports conditions
  • Webhook verification helpers built on standardwebhooks for validating Clerk webhook payloads
  • The shared foundation consumed by every framework-specific Clerk SDK (Next.js, Express, Fastify, Remix, Hono, Astro, Nuxt)

Common Use Cases

  • Verifying incoming request session tokens in custom middleware for a framework Clerk doesn’t ship a dedicated SDK for
  • Calling the Clerk Backend API directly to manage users, organizations, or sessions from server-side code or scripts
  • Validating and processing Clerk webhook events (user created, session ended, etc.) in a backend handler
  • Building a custom framework integration on top of Clerk’s authentication primitives

Under The Hood

Architecture - @clerk/backend sits at packages/backend inside the clerk/javascript monorepo and is organized around two pillars: a generated REST client under src/api/endpoints/ (one class per resource such as UserApi, SessionApi, OAuthApplicationsApi, BillingApi, M2MTokenApi) built on a shared AbstractApi/factory.ts request pipeline, and a tokens/ module implementing local JWT verification so requests can be authenticated without calling the API. webhooks.ts and createRedirect.ts provide supporting helpers, and index.ts re-exports the public surface consumed by every framework SDK in the monorepo.

Tech Stack - Written in TypeScript, built with tsup, and dependent on @clerk/shared (cross-package utilities), standardwebhooks (webhook signature verification), and tslib. Package exports use conditional imports (#crypto) to select a Node-specific crypto implementation versus a browser/edge-light one, letting the same published package run correctly on Node.js, Cloudflare Workers, and other V8-isolate runtimes without a separate build.

Code Quality - Tests live under src/__tests__/ (webhooks, exports, createRedirect, proxy) using Vitest-style specs, with msw for mocking HTTP calls to the Backend API in tests; the surface area is large (dozens of endpoint classes) but each follows the same AbstractApi pattern, keeping naming and request/response shapes consistent across resources.

API Design - The client groups methods by resource (e.g. clerkClient.users.getUser(), clerkClient.sessions.verifySession()), mirroring the Backend API’s REST structure, which keeps the API predictable once a developer learns the pattern for one resource. Getting started requires an API secret key and, for most apps, pulling in a framework-specific package (e.g. @clerk/nextjs) rather than calling @clerk/backend directly — a small amount of indirection that pays off in consistent framework ergonomics.

Used by 5 apps in this directory

TypeScript
99%
Apache 2.0

Bubble Lab

Automation · AI Development

1,095

Open-core workflow engine for building AI-powered automations in TypeScript that run natively inside Slack — no context switching required.

View details
35
Repo Health
78
Technical
72
Dependency
Built with
TypeScript99%
Updated 3 months ago
TypeScript
45%
Other

Convex Backend

Developer Tools · Databases

12,394

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
88
Repo Health
82
Technical
70
Dependency
Built with
TypeScript45%
Rust43%
Updated today
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

27,294

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
88
Repo Health
73
Technical
66
Dependency
Built with
TypeScript99%
Updated today
TypeScript
98%
Other

Novu

Developer Tools

39,615

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
65
Dependency
Built with
TypeScript98%
Updated today
TypeScript
98%
Apache 2.0

TinaCMS

CMS

13,732

An open-source, Git-backed headless CMS that gives editors a live visual editing UI over Markdown, MDX, JSON, and YAML content while developers keep everything in version control.

View details
92
Repo Health
74
Technical
64
Dependency
Built with
TypeScript98%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search