Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Clerk · Function

createClerkClient

Creates a customized Clerk Backend API client for JavaScript environments. Provide a Clerk Secret Key in the options object, then use the returned client for server-side resources such as users and invitations.

How it works

createClerkClient() constructs a customized Backend API client for JavaScript environments. Pass an options object containing at least the Clerk Secret Key, then use the returned client to call resources such as users or invitations.

Syntax

createClerkClient(options)

Parameters

NameTypeDescription
optionsobjectConfiguration object for the client; it must include the Clerk Secret Key and may include other supported options.

Returns

A customized Clerk client instance that wraps the Backend API.

Key points

  • The returned object simplifies server-side interaction with Clerk's Backend API.
  • Instantiation requires passing the Clerk Secret Key through the options object.
  • Additional options can customize the created client's behavior.
  • The documented configuration pattern reads the secret key from CLERK_SECRET_KEY.

Common mistakes

  • A secretKey is required when creating the backend client; do not omit it.
  • Keep sensitive configuration such as the secret key in environment variables rather than hard-coding it.

Example: Create a backend Clerk client

import { createClerkClient } from '@clerk/backend'

const clerkClient = createClerkClient({
  secretKey: process.env.CLERK_SECRET_KEY,
})

const users = await clerkClient.users.getUserList()
console.log(users)

Creates a backend Clerk client with the server-side secret key, then retrieves the user list.

When to use it

Custom backend client

Create a server-side Clerk client with application-specific configuration.

Manage users

Call Backend API resources such as user management operations.

Backend authentication integration

Use server-side Clerk functionality from a JavaScript or TypeScript application.

Interview questions

QWhat does createClerkClient() provide?

It creates a wrapper around Clerk's Backend API for JavaScript environments. The returned client exposes resource APIs, such as users, for server-side operations.

Follow-up: How would you avoid exposing credentials? Pass the secret key from a server-side environment variable, such as process.env.CLERK_SECRET_KEY, and never ship it to browser code.

QHow do you instantiate and use the client?

Call createClerkClient() with an options object and provide secretKey. The resulting client can then be used for operations such as clerkClient.users.getUserList().

Follow-up: What is a useful customization pattern? Supply additional supported options alongside secretKey when the application needs to customize the client.

QWhy create a custom client instead of using the default client?

The function is useful when the default clerkClient instance is not sufficient. It lets an application create a custom instance with its own options while retaining access to the Backend API.

Follow-up: When should a default instance be preferred? Use the SDK's default client when the standard environment-based configuration meets the application's needs.

  • clerkClient
  • users.getUserList()
  • invitations.createInvitation()
  • authenticateRequest()

Source: clerkClient | Clerk Docs. Checked 2026-10-15.