Search…
Configuration
The SDK can be configured in three ways: environment variables, configuration singleton and constructor arguments. The priority goes like this:
  1. 1.
    Constructor arguments
  2. 2.
    Configuration object
  3. 3.
    Environment variables
If an argument is not provided, the configuration object is looked up, which falls back to the associated environment variable. Here's an example with all supported configuration settings their environment variable equivalents:
1
Clerk.configure do |c|
2
c.api_key = "your_api_key" # if omitted: ENV["CLERK_API_KEY"] - API calls will fail if unset
3
c.base_url = "https://..." # if omitted: "https://api.clerk.dev/v1/"
4
c.logger = Logger.new(STDOUT) # if omitted, no logging
5
c.middleware_cache_store = Rails.cache # if omitted: no caching
6
end
Copied!
You can customize each instance of the Clerk::SDK object by passing keyword arguments to the constructor:
1
clerk = Clerk::SDK.new(
2
api_key: "X",
3
base_url: "Y",
4
logger: Logger.new()
5
)
Copied!
For full customization, you can instead pass a Faraday object directly, which will ignore all the other arguments, if passed:
1
faraday = Faraday.new()
2
clerk = Clerk::SDK.new(connection: faraday)
Copied!
Refer to the Faraday documentation for details.

Environment variables

Here's a list of all environment variables the SDK uses:
Variable name
Usage
CLERK_API_BASE
Overrides the default API base URL: https://api.clerk.dev/v1/
CLERK_API_KEY
The API key of your instance (required)
CLERK_SIGN_IN_URL
Rails view helper: clerk_sign_in_url
CLERK_SIGN_UP_URL
Rails view helper: clerk_sign_up_url
CLERK_USER_PROFILE_URL
Rails view helper: clerk_user_profile_url
Last modified 3mo ago
Copy link
Edit on GitHub