rootAuthLoader()
The rootAuthLoader()
function is a helper function that provides the authentication state to your Remix application.
Usage
You can use the rootAuthLoader()
in two different ways:
- Without a callback, which will just return the auth state
- With a callback function to handle custom data loading while having access to auth state
You can also pass configuration options to rootAuthLoader()
no matter which method you use.
Without a callback
To configure Clerk in your Remix app, you must export the rootAuthLoader()
function as the root loader()
function.
With a callback
If you need to load in additional data, you can pass a callback to rootAuthLoader()
that handles the route data loading with auth state.
Pass configuration options
To pass configuration options to rootAuthLoader()
, you can pass an optional argument to the rootAuthLoader()
function.
The rootAuthLoader()
function accepts an optional object. The following options are available:
- Name
audience?
- Type
string | string[]
- Description
A string or list of audiences. If passed, it is checked against the
aud
claim in the token.
- Name
authorizedParties?
- Type
string[]
- Description
An allowlist of origins to verify against, to protect your application from the subdomain cookie leaking attack.
For example:['http://localhost:3000', 'https://example.com']
- Name
domain?
- Type
string
- Description
The domain used for satellites to inform Clerk where this application is deployed.
- Name
isSatellite?
- Type
boolean
- Description
When using Clerk's satellite feature, this should be set to
true
for secondary domains.
- Name
jwtKey
- Type
string
- Description
Used to verify the session token in a networkless manner. Supply the PEM public key from the API keys page -> Show JWT public key -> PEM Public Key section in the Clerk Dashboard. It's recommended to use the environment variable instead. For more information, refer to Manual JWT verification.
- Name
proxyUrl?
- Type
string
- Description
Specify the URL of the proxy, if using a proxy.
- Name
publishableKey
- Type
string
- Description
The Clerk Publishable Key for your instance. This can be found in the API keys page -> Show Publishable Key section in the Clerk Dashboard. It's recommended to use the environment variable instead.
- Name
secretKey?
- Type
string
- Description
The Clerk Secret Key for your instance. This can be found on the API keys page in the Clerk Dashboard. It's recommended to use the environment variable instead.
- Name
signInUrl
- Type
string
- Description
This URL will be used for any redirects that might happen and needs to point to your primary application on the client-side. This option is optional for production instances. It is required to be set for a satellite application in a development instance. It's recommended to use the environment variable instead.
- Name
signUpUrl
- Type
string
- Description
This URL will be used for any redirects that might happen and needs to point to your primary application on the client-side. This option is optional for production instances but must be set for a satellite application in a development instance. It's recommended to use the environment variable instead.
- Name
signInFallbackRedirectUrl?
- Type
string
- Description
The fallback URL to redirect to after the user signs in, if there's no
redirect_url
in the path already. Defaults to/
. It's recommended to use the environment variable instead.
- Name
signUpFallbackRedirectUrl?
- Type
string
- Description
The fallback URL to redirect to after the user signs up, if there's no
redirect_url
in the path already. Defaults to/
. It's recommended to use the environment variable instead.
- Name
signInForceRedirectUrl?
- Type
string
- Description
If provided, this URL will always be redirected to after the user signs in. It's recommended to use the environment variable instead.
- Name
signUpForceRedirectUrl?
- Type
string
- Description
If provided, this URL will always be redirected to after the user signs up. It's recommended to use the environment variable instead.
Feedback
Last updated on