https://github.com/clerk/clerk-convex-swift
ClerkConvex helps developers add Clerk-powered user management to Convex Swift apps. We automatically sync sessions and tokens so users can sign in once and stay authenticated.
https://github.com/clerk/clerk-convex-swift
Last synced: 5 months ago
JSON representation
ClerkConvex helps developers add Clerk-powered user management to Convex Swift apps. We automatically sync sessions and tokens so users can sign in once and stay authenticated.
- Host: GitHub
- URL: https://github.com/clerk/clerk-convex-swift
- Owner: clerk
- License: mit
- Created: 2026-02-05T21:57:14.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-02-11T21:46:24.000Z (5 months ago)
- Last Synced: 2026-02-12T06:06:20.164Z (5 months ago)
- Language: Swift
- Homepage:
- Size: 108 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ClerkConvex
**Status:** 🚧 Work in Progress — contents are unstable and subject to change.
`ClerkConvex` is a Swift package that bridges Clerk and Convex by automatically syncing Clerk session auth into `ConvexClientWithAuth`.
## Getting Started
If you haven't started a Convex app yet, begin with the
[Convex Swift quickstart](https://docs.convex.dev/quickstart/swift) to get a working
Swift app connected to Convex.
Once you have a working Convex + Swift app, use the steps below to integrate Clerk.
Follow the [Clerk iOS quickstart](https://clerk.com/docs/ios/getting-started/quickstart) for app-side Clerk setup details.
1. Set up Clerk in your iOS app (create an app in Clerk, get your publishable key, and add Clerk SDK dependencies).
2. Configure Convex auth by creating `convex/auth.config.ts`:
```typescript
export default {
providers: [
{
domain: "YOUR_CLERK_ISSUER_URL",
applicationID: "convex",
},
],
};
```
3. Run `npx convex dev` to sync backend auth configuration.
4. Add `ClerkConvex` to your app.
5. Wherever you currently create `ConvexClient`, switch to `ConvexClientWithAuth` and pass `ClerkConvexAuthProvider`:
```swift
import ClerkKit
import ClerkConvex
import ConvexMobile
Clerk.configure(publishableKey: "YOUR_CLERK_PUBLISHABLE_KEY")
let client = ConvexClientWithAuth(
deploymentUrl: "YOUR_CONVEX_DEPLOYMENT_URL",
authProvider: ClerkConvexAuthProvider()
)
```
6. Authenticate users via Clerk; auth state is automatically synced to Convex.
### Reacting to authentication state
The `ConvexClientWithAuth.authState` field is a `Publisher` that contains the latest authentication state from the client. You can set up your UI to react to new `authState` values and show the appropriate screens (e.g. login/logout buttons, loading screens, authenticated content).
## Example App
This repo includes a full example app at `Example/WorkoutTracker`.
Open `ClerkConvex.xcworkspace` and run the `WorkoutTracker` scheme.