@auth0/nextjs-auth0 - v4.8.0
    Preparing search index...

    Class Auth0Client

    Index

    Constructors

    Methods

    • Parameters

      • Optionaloptions: GetAccessTokenOptions

        Optional configuration for getting the access token.

        • refresh

          Force a refresh of the access token.

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

    • getAccessToken returns the access token.

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

      Parameters

      • req: NextRequest | PagesRouterRequest

        The request object.

      • res: NextResponse<unknown> | PagesRouterResponse

        The response object.

      • Optionaloptions: GetAccessTokenOptions

        Optional configuration for getting the access token.

        • refresh

          Force a refresh of the access token.

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

    • Retrieves an access token for a connection.

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

      NOTE: Server Components cannot set cookies. Calling getAccessTokenForConnection() 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 getAccessTokenForConnection(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 }>

    • Retrieves an access token for a connection.

      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>