Skip to Content
API ReferenceServerFunctionsFunction: currentUser()

@authgear/nextjs


@authgear/nextjs / server / currentUser

Function: currentUser()

currentUser(config): Promise<UserInfo | null>

Defined in: src/server.ts:68 

Get the current user in a Server Component or Route Handler. Automatically refreshes the access token if expired, including persisting a rotated refresh token when the Authgear project has refresh token rotation enabled. Returns null if not authenticated or if the session cannot be refreshed.

Parameters

config

AuthgearConfig

Returns

Promise<UserInfo | null>

Last updated on