@clerk/backend

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

SDK
npm
v3.26.2
1,768 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
92 /100 Excellent
Development Activity 100
Maintenance 100
Community 72
Maturity 56
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 87
Code Quality 88
Innovation 85
Learning Curve 78

@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 16 apps in this directory

TypeScript
98%
Other

Novu

Developer Tools

40,195

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
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,195

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
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
Python
79%
AGPL 3.0

Skyvern

AI Agents · Automation

23,257

Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Python 79%
TypeScript 19%
Updated 6 days ago
TypeScript
72%
Apache 2.0

Supabase

Authentication · Databases · Developer Tools

113,827

The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.

View details
90
Repo Health
91
Technical
62
Dependency
Built with
TypeScript 72%
MDX 26%
Updated 6 days ago
TypeScript
98%
Apache 2.0

TinaCMS

CMS

13,845

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
59
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
98%
Apache 2.0

TinaCMS

CMS

13,845

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
59
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
50%
Other

World Monitor

Analytics · Monitoring

89,376

Real-time global intelligence dashboard that fuses AI-synthesized news, geopolitical risk scoring, and infrastructure tracking into one open-source situational awareness platform.

View details
87
Repo Health
89
Technical
68
Dependency
Built with
TypeScript 50%
JavaScript 48%
Updated 6 days ago

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