
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
@clerk/backend
Advanced tools
This package provides Clerk Backend API resources and low-level authentication utilities for JavaScript environments. It is mostly used as the base for other Clerk SDKs but it can be also used on its own.
CLERK_SECRET_KEY for multiple instance REST access.{data, errors} instead of throwing errors.Works on Node.js >=18.17.0 (or later) or on any V8 Isolates runtimes (eg Cloudflare Workers).
npm install @clerk/backend
import { createClerkClient } from '@clerk/backend';
const clerk = createClerkClient({ secretKey: '...' });
await clerk.users.getUser("user_...");
Create Clerk SDK that includes an HTTP Rest client for the Backend API and session verification helpers. The clerk object contains the following APIs and methods:
import { createClerkClient } from '@clerk/backend';
const clerk = createClerkClient({ secretKey: '...' });
await clerk.users.getUser('user_...');
// Available APIs
clerk.allowlistIdentifiers;
clerk.clients;
clerk.emailAddresses;
clerk.emails;
clerk.invitations;
clerk.organizations;
clerk.phoneNumbers;
clerk.redirectUrls;
clerk.sessions;
clerk.signInTokens;
clerk.users;
// These functions should be used by framework-specific libraries, such as @clerk/nextjs or @clerk/remix.
// Compute the authentication state given the request parameters.
clerk.authenticateRequest(options);
// Build debug payload of the request state.
clerk.debugRequestState(requestState);
Verifies a Clerk generated JWT (i.e. Clerk Session JWT and Clerk JWT templates). The key resolution via JWKS or local values is handled automatically.
import { verifyToken } from '@clerk/backend';
const { result, error } = await verifyToken(token, {
issuer: '...',
authorizedParties: '...',
});
Verifies a Clerk generated JWT (i.e. Clerk Session JWT and Clerk JWT templates). The key needs to be provided in the options.
import { verifyJwt } from '@clerk/backend/jwt';
const { result, error } = verifyJwt(token, {
key: JsonWebKey | string,
authorizedParties: '...',
});
Decodes a JWT.
import { decodeJwt } from '@clerk/backend/jwt';
const { result, error } = decodeJwt(token);
Verifies that the JWT has a valid signature. The key needs to be provided.
import { hasValidSignature } from '@clerk/backend/jwt';
const { result, error } = await hasValidSignature(token, jwk);
Generates a debug payload for the request state
import { debugRequestState } from '@clerk/backend/internal';
debugRequestState(requestState);
Builds the AuthObject when the user is signed in.
import { signedInAuthObject } from '@clerk/backend/internal';
signedInAuthObject(jwtPayload, options);
Builds the empty AuthObject when the user is signed out.
import { signedOutAuthObject } from '@clerk/backend/internal';
signedOutAuthObject();
Removes sensitive private metadata from user and organization resources in the AuthObject
import { sanitizeAuthObject } from '@clerk/backend/internal';
sanitizeAuthObject(authObject);
Removes any private_metadata and privateMetadata attributes from the object to avoid leaking sensitive information to the browser during SSR.
import { prunePrivateMetadata } from '@clerk/backend/internal';
prunePrivateMetadata(obj);
You can get in touch with us in any of the following ways:
We're open to all community contributions! If you'd like to contribute in any way, please read our contribution guidelines.
@clerk/backend follows good practices of security, but 100% security cannot be assured.
@clerk/backend is provided "as is" without any warranty. Use at your own risk.
For more information and to report security issues, please refer to our security documentation.
This project is licensed under the MIT license.
See LICENSE for more information.
Auth0 is a flexible, drop-in solution to add authentication and authorization services to your applications. It provides a wide range of features including social login, multi-factor authentication, and user management. Compared to @clerk/backend, Auth0 offers more extensive integrations and a broader set of features but can be more complex to set up.
Firebase Admin SDK allows you to integrate Firebase services into your server-side applications. It provides functionalities for user authentication, database management, and cloud messaging. Compared to @clerk/backend, Firebase Admin SDK offers a more comprehensive suite of backend services but may require more configuration and setup.
Passport is an authentication middleware for Node.js that supports a wide range of authentication strategies. It is highly modular and can be integrated with various authentication providers. Compared to @clerk/backend, Passport is more flexible and customizable but requires more effort to implement and manage different authentication strategies.
FAQs
Clerk Backend SDK - REST Client for Backend API & JWT verification utilities
The npm package @clerk/backend receives a total of 640,148 weekly downloads. As such, @clerk/backend popularity was classified as popular.
We found that @clerk/backend demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.