getAccessToken returns the access token.
This method can be used in middleware and getServerSideProps
, API routes in the Pages Router.
getSession returns the session data for the current request.
This method can be used in Server Components, Server Actions, and Route Handlers in the App Router.
getSession returns the session data for the current request.
This method can be used in middleware and getServerSideProps
, API routes in the Pages Router.
middleware mounts the SDK routes to run as a middleware function.
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.
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.
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 callgetAccessToken(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.