You're asking about managing Clerk authentication with Convex preview deployments, which is a common challenge when working with these two services together.
Clerk and Convex Preview Deployments
Convex preview deployments are not predictable in the sense that they don't have stable URLs - they use randomly generated names (like "happy-animal-123.convex.cloud") rather than branch-based URLs. This makes webhook configuration challenging for preview environments.
For setting up Clerk with Convex preview deployments, here are some approaches:
1. Environment Variables for Preview Deployments
You can set environment variables for your preview deployments using the --preview-name flag with the Convex CLI:
npx convex env set --preview-name $VERCEL_GIT_COMMIT_REF CLERK_JWT_ISSUER_DOMAIN your-value
This allows you to configure the Clerk JWT issuer domain for each preview deployment based on a Discord thread.
2. Default Environment Variables
Convex allows you to set default environment variables that apply to all preview deployments:
npx convex env set --default CLERK_JWT_ISSUER_DOMAIN your-value
This approach is mentioned by a Convex support staff member as "the closest solution is using default environment variables, which apply to all new preview deployments, but also to all new dev deployments" in this Discord thread.
3. Alternative Authentication for Previews
Some developers opt to use a simpler authentication method just for preview environments:
- Enable email/password login only in preview/dev environments
- Create test user buttons that appear only in preview/dev
- This avoids the webhook complexity entirely for non-production environments