Configure the SDK
Call Clerk.configure(publishableKey:options:) once at app launch before accessing Clerk.shared or @Environment(Clerk.self).
Basic configuration
import ClerkKit
import SwiftUI
@main
struct MyApp: App {
init() {
Clerk.configure(publishableKey: "YOUR_PUBLISHABLE_KEY")
}
var body: some Scene {
WindowGroup {
ContentView()
.environment(Clerk.shared)
}
}
}Configuration options
Use Clerk.Options to customize logging, telemetry, redirects, and more.
let options = Clerk.Options(
logLevel: .debug,
telemetryEnabled: true,
keychainConfig: .init(
service: "com.example.shared-auth",
accessGroup: "ABCDE12345.com.example.shared-auth"
),
proxyUrl: "https://proxy.example.com/__clerk",
redirectConfig: .init(
redirectUrl: "myapp://callback",
callbackUrlScheme: "myapp"
),
watchConnectivityEnabled: true,
sharedSessionSync: .enabled,
loggerHandler: { logEntry in
print("[Clerk] \(logEntry.message)")
},
middleware: .init(
request: [
CustomHeaderMiddleware()
],
response: [
ResponseDiagnosticsMiddleware()
]
)
)
Clerk.configure(publishableKey: "YOUR_PUBLISHABLE_KEY", options: options)- Name
logLevel- Type
LogLevel- Description
Minimum SDK log level. Defaults to
.error.
- Name
telemetryEnabled- Type
Bool- Description
Enables development telemetry collection. Defaults to
true.
- Name
keychainConfig- Type
- Clerk.Options.KeychainConfig
- Description
Controls Keychain storage behavior.
- Name
proxyUrl- Type
URL?- Description
Proxy URL for apps behind a reverse proxy, e.g.,
https://proxy.example.com/__clerk.
- Name
redirectConfig- Type
- Clerk.Options.RedirectConfig
- Description
OAuth redirect URLs and callback handling.
- Name
watchConnectivityEnabled- Type
Bool- Description
Sync auth state to a watchOS companion app. Defaults to
false.
- Name
sharedSessionSync- Type
- Clerk.Options.SharedSessionSyncConfig?
- Description
Enables shared session sync between sibling apps on the same Apple Developer Team that share the same Keychain service and access group. All participating apps must also use the same Clerk . Defaults to
nil. See Share sessions across apps.
- Name
loggerHandler- Type
(@Sendable (LogEntry) -> Void)?- Description
Callback for error-level SDK logs.
- Name
middleware- Type
- Clerk.Options.MiddlewareConfig
- Description
Configuration for request/response middleware.
- Name
service- Type
String- Description
Keychain service name. Defaults to the app bundle identifier.
- Name
accessGroup- Type
String?- Description
Access group for Keychain item sharing.
- Name
redirectUrl- Type
String- Description
OAuth redirect URL. Defaults to
{bundleIdentifier}://callback.
- Name
callbackUrlScheme- Type
String- Description
Callback URL scheme. Defaults to the app bundle identifier.
- Name
.enabled- Type
Clerk.Options.SharedSessionSyncConfig- Description
Turns on shared session sync between sibling apps. Requires a Keychain service and access group. See Share sessions across apps.
- Name
request- Type
[ClerkRequestMiddleware]- Description
Final-step request middleware for custom headers or diagnostics.
- Name
response- Type
[ClerkResponseMiddleware]- Description
Response middleware that runs immediately after a response is received. Custom response middleware runs before Clerk's built-in response middleware.
Clerk
Learn how to access Clerk in your app.
iOS Quickstart
Follow the end-to-end setup guide for a Clerk-powered iOS app.
Feedback
Last updated on