clerk-convex-kotlin is an Android library that bridges Clerk and Convex by automatically syncing Clerk session auth into ConvexClientWithAuth.
If you haven't started a Convex app yet, begin with the Convex Android quickstart to get a working Android app connected to Convex.
Once you have a working Convex + Android app, use the steps below to integrate Clerk. Follow the Clerk Android quickstart for app-side Clerk setup details.
-
Set up Clerk in your Android app (create an app in Clerk, get your publishable key, and add Clerk SDK dependencies).
-
Configure Convex auth by creating
convex/auth.config.ts:export default { providers: [ { domain: "YOUR_CLERK_FRONTEND_API_URL", applicationID: "convex", }, ], };
-
Run
npx convex devto sync backend auth configuration. -
Add
clerk-convex-kotlinto your app:// build.gradle.kts dependencies { implementation("com.clerk:clerk-convex-kotlin:<latest-version>") }
-
Wherever you currently create
ConvexClient, switch to the provided Clerk helper factory.import com.clerk.convex.createClerkConvexClient val client = createClerkConvexClient( deploymentUrl = "YOUR_CONVEX_DEPLOYMENT_URL", context = applicationContext )
-
Authenticate users via Clerk. Auth state is automatically synced to convex
The ConvexClientWithAuth.authState is a StateFlow that contains the latest authentication state from the client.
You can set up your UI to react to new authState values, (e.g. login/logout, loading, authenticated content)
This repo includes a full example at /samples/workout-tracker.