Clerk.Config (Clerk SDK v2.0.0)

Configuration for a Clerk tenant connection.

Build a config with new/1, start the supervisor with {Clerk, config}, and pass the same struct to API calls and plugs via the config: option.

Examples

config =
  Clerk.Config.new(
    name: AppA.Clerk,
    domain: "app-a.clerk.accounts.dev",
    secret_key: System.fetch_env!("APP_A_CLERK_SECRET_KEY"),
    fetching_strategy: AppA.Clerk.FetchingStrategy
  )

children = [{Clerk, config}]
Clerk.User.list(%{}, config: config)

Summary

Functions

Returns the default config built from config :clerk application config.

Builds a %Clerk.Config{} from keyword options.

Types

@type t() :: %Clerk.Config{
  authorized_parties: [String.t()] | nil,
  domain: String.t(),
  fetching_strategy: module(),
  http_name: atom(),
  name: atom(),
  secret_key: String.t() | nil,
  should_start: term()
}

Functions

Returns the default config built from config :clerk application config.

Equivalent to passing Application.get_all_env(:clerk) to {Clerk, ...}. Used automatically when API calls omit config:.

Builds a %Clerk.Config{} from keyword options.

Required:

  • :domain - the Clerk Frontend API domain (e.g. "app.clerk.accounts.dev")

Optional:

  • :name - supervisor and process name. Defaults to Clerk.
  • :secret_key - Backend API secret key.
  • :authorized_parties - allowlist for JWT azp claim validation.
  • :fetching_strategy - JWKS fetching strategy module. Required when :name is not Clerk.
  • :http_name - Finch pool name. Derived from :name when omitted.