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.
It is important to protect your API routes to ensure that only authenticated users can access them. You can do this by checking if the userId is present in the getAuth() response, as shown in the following example:
getAuth() returns getToken(), which is a method that returns the current user's session token. You can also use this function to retrieve a token from a custom JWT template and use it to fetch data from an external source, as shown in the following example:
clerkClient is used to access the Backend SDK, which exposes Clerk's Backend API resources. You can use getAuth() to pass authentication information that many of the Backend SDK methods require, like in the following example: