Skip to Content
API ReferenceServerFunctionsFunction: auth()

@authgear/nextjs


@authgear/nextjs / server / auth

Function: auth()

auth(config): Promise<Session>

Defined in: src/server.ts:19 

Read the current session in a Server Component, Route Handler, or Server Action. Automatically refreshes the access token if expired, so session.accessToken is always valid when the session state is Authenticated. Use this when you need a fresh access token to call a downstream API (e.g. inside a Server Action).

Parameters

config

AuthgearConfig

Returns

Promise<Session>

Last updated on