Skip to main content
Docs

getAuth()

The getAuth() helper retrieves authentication state from the request object.

Note

If you are using App Router, use the auth() helper instead.

  • Name
    req
    Description

    The Next.js request object.

  • Name
    opts?
    Description

    An optional object that can be used to configure the behavior of the getAuth() function. It accepts the following properties:

    • secretKey?: A string that represents the Secret Key used to sign the session token. If not provided, the Secret Key is retrieved from the environment variable CLERK_SECRET_KEY.

Returns

getAuth() returns the Auth object. See the Auth reference for more information.

Usage

See the dedicated guide for example usage.

Feedback

What did you think of this content?

Last updated on