Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(custom-session-token) add usage info for non-nextjs frameworks #1827

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading