Constructors

Methods

  • getAccessToken returns the access token.

    This method can be used in Server Components, Server Actions, and Route Handlers in the App Router.

    NOTE: Server Components cannot set cookies. Calling getAccessToken() in a Server Component will cause the access token to be refreshed, if it is expired, and the updated token set will not to be persisted. It is recommended to call getAccessToken(req, res) in the middleware if you need to retrieve the access token in a Server Component to ensure the updated token set is persisted.

    Returns Promise<{ expiresAt: number; token: string }>

  • getAccessToken returns the access token.

    This method can be used in middleware and getServerSideProps, API routes in the Pages Router.

    Parameters

    Returns Promise<{ expiresAt: number; token: string }>

  • middleware mounts the SDK routes to run as a middleware function.

    Parameters

    • req: NextRequest

    Returns Promise<NextResponse<unknown>>

  • updateSession updates the session of the currently authenticated user. If the user does not have a session, an error is thrown.

    This method can be used in middleware and getServerSideProps, API routes, and middleware in the Pages Router.

    Parameters

    Returns Promise<void>

  • updateSession updates the session of the currently authenticated user. If the user does not have a session, an error is thrown.

    This method can be used in Server Actions and Route Handlers in the App Router.

    Parameters

    Returns Promise<void>