Skip to content

Commit

Permalink
(custom-session-token) add usage info for non-nextjs frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisintech committed Dec 18, 2024
1 parent 8107930 commit 4678811
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions docs/backend-requests/making/custom-session-token.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@ This guide will show you how to customize a session token to include additional

## Use the custom claims in your application

The [`Auth`](/docs/references/nextjs/auth-object) object in the `@clerk/nextjs` package includes a `sessionClaims` property that contains the custom claims you added to your session token.
The [`Auth`](/docs/references/nextjs/auth-object) object includes a `sessionClaims` property that contains the custom claims you added to your session token. It's returned by the [`useAuth()`](/docs/references/react/use-auth) hook, the [`auth()`](/docs/references/nextjs/auth) and `getAuth()` helpers, and the `request` object in server contexts.

Access the custom claims in your application by calling `auth()` in App Router applications or `getAuth(req)` in Pages Router applications.

The following example demonstrates how to access the `fullName` and `primaryEmail` claims that were added to the session token in the last step.
The following example demonstrates how to access the `fullName` and `primaryEmail` claims that were added to the session token in the last step. This examples are written for Next.js, but they can be adapted to other frameworks by using the appropriate method for accessing the `Auth` object.

<CodeBlockTabs options={["App Router", "Pages Router"]}>
```tsx {{ filename: 'app/page.tsx' }}
```tsx {{ filename: 'app/api/example/route.tsx' }}
import { auth } from '@clerk/nextjs/server'
import { NextResponse } from 'next/server'

export default async function Page() {
export async function GET() {
const { sessionClaims } = await auth()

const fullName = sessionClaims?.fullName
Expand Down

0 comments on commit 4678811

Please sign in to comment.