Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

Customize your session token

Session tokens are JWTs generated by Clerk on behalf of your instance, and convey an authenticated user session to your backend.

They typically contain a standard set of claims that are required for Clerk to function. However, you can customize them and retrieve the data at any point.

Clerk has default claims that will be included in this session token. You can read about Clerk's session tokens and it's default claims.

How to Customize your session token?

Go to Sessions in the Clerk Dashboard

Firstly you need to go to the Sessions tab in the Clerk Dashboard.

Clerk Dashboard with a session token

Click the Edit button

Next from the menu select the Edit button.

Clerk Dashboard with an arrow pointing to the edit

Add a new claim to the session token

At this point, you are able to select all the session tokens you need. This examples adds a new claim called fullName and primaryEmail to the session token.

Clerk Dashboard showing the custom claim modal

Using the custom claims in your application

Now that you have added the custom claims to your session token, you can use them in your application. Below is an example of how you can access the custom claims in your application.

Using getAuth in your Next.js application

import { getAuth } from "@clerk/nextjs/server"; export default async function handler(req, res) { const { sessionClaims } = getAuth(req); const firstName = sessionClaims.fullName; const primaryEmail = sessionClaims.primaryEmail; return res.status(200).json({ firstName, primaryEmail }) }

What did you think of this content?

Clerk © 2023