Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Set up Convex authentication with Convex Auth, Clerk, WorkOS AuthKit, Auth0, or custom JWT providers.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/auth0.md
1# Auth023Official docs:45- https://docs.convex.dev/auth/auth06- https://auth0.github.io/auth0-cli/7- https://auth0.github.io/auth0-cli/auth0_apps_create.html89Use this when the app already uses Auth0 or the user wants Auth0 specifically.1011## Workflow12131. Confirm the user wants Auth0142. Determine the app framework and whether Auth0 is already partly set up153. Ask whether the user wants local-only setup or production-ready setup now164. Read the official Convex and Auth0 guides before making changes175. Ask whether they want the fastest setup path by installing the Auth0 CLI186. If they agree, install the Auth0 CLI and do as much of the Auth0 app setup as19possible through the CLI207. If they do not want the CLI path, use the Auth0 dashboard path instead218. Complete the relevant Auth0 frontend quickstart if the app does not already22have Auth0 wired up239. Configure `convex/auth.config.ts` with the Auth0 domain and client ID2410. Set environment variables for local and production environments2511. Wrap the app with `Auth0Provider` and `ConvexProviderWithAuth0`2612. Gate Convex-backed UI with Convex auth state2713. Try to verify Convex reports the user as authenticated after Auth0 login2814. If the refresh-token path fails, stop improvising and send the user back to29the official docs3015. If the user wants production-ready setup, make sure the production Auth031tenant and env vars are also covered3233## What To Do3435- Read the official Convex and Auth0 guide before writing setup code36- Prefer the Auth0 CLI path for mechanical setup if the user is willing to37install it, but do not present it as a fully validated end-to-end path yet38- Ask the user directly: "The fastest path is to install the Auth0 CLI so I can39do more of this for you. If you want, I can install it and then only ask you40to log in when needed. Would you like me to do that?"41- Make sure the app has already completed the relevant Auth0 quickstart for its42frontend43- Use the official examples for `Auth0Provider` and `ConvexProviderWithAuth0`44- If the Auth0 login or refresh flow starts failing in a way that is not clearly45explained by the docs, say that plainly and fall back to the official docs46instead of pretending the flow is validated4748## Key Setup Areas4950- install the Auth0 SDK for the app's framework51- configure `convex/auth.config.ts` with the Auth0 domain and client ID52- set environment variables for local and production environments53- wrap the app with `Auth0Provider` and `ConvexProviderWithAuth0`54- use Convex auth state when gating Convex-backed UI5556## Files and Env Vars To Expect5758- `convex/auth.config.ts`59- frontend app entry or provider wrapper60- Auth0 CLI install docs: `https://auth0.github.io/auth0-cli/`61- Auth0 environment variables commonly include:62- `AUTH0_DOMAIN`63- `AUTH0_CLIENT_ID`64- `VITE_AUTH0_DOMAIN`65- `VITE_AUTH0_CLIENT_ID`6667## Concrete Steps68691. Start by reading `https://docs.convex.dev/auth/auth0` and the relevant Auth070quickstart for the app's framework712. Ask whether the user wants the Auth0 CLI path723. If yes, install Auth0 CLI and have the user authenticate it with73`auth0 login`744. Use `auth0 apps create` with SPA settings, callback URL, logout URL, and web75origins if creating a new app765. If not using the CLI path, complete the relevant Auth0 frontend quickstart77and create the Auth0 app in the dashboard786. Get the Auth0 domain and client ID from the CLI output or the Auth0 dashboard797. Install the Auth0 SDK for the app's framework808. Create or update `convex/auth.config.ts` with the Auth0 domain and client ID819. Set frontend and backend environment variables8210. Wrap the app in `Auth0Provider`8311. Replace plain `ConvexProvider` wiring with `ConvexProviderWithAuth0`8412. Run the normal Convex dev or deploy flow after backend config changes8513. Try the official provider config shown in the Convex docs8614. If login works but Convex auth or token refresh fails in a way you cannot87clearly resolve, stop and tell the user to follow the official docs manually88for now8915. Only claim success if the user can sign in and Convex recognizes the90authenticated session9116. If the user wants production-ready setup, configure the production Auth092tenant values and production environment variables too9394## Gotchas9596- The Convex docs assume the Auth0 side is already set up, so do not skip the97Auth0 quickstart if the app is starting from scratch98- The Auth0 CLI is often the fastest path for a fresh setup, but it still99requires the user to authenticate the CLI to their Auth0 tenant100- If the user agrees to install the Auth0 CLI, do the mechanical setup yourself101instead of bouncing them through the dashboard102- If login succeeds but Convex still reports unauthenticated, double-check103`convex/auth.config.ts` and whether the backend config was synced104- We were able to automate Auth0 app creation and Convex config wiring, but we105did not fully validate the refresh-token path end to end106- In validation, the documented `useRefreshTokens={true}` and107`cacheLocation="localstorage"` setup hit refresh-token failures, so do not108present that path as settled109- If you hit Auth0 errors like `Unknown or invalid refresh token`, do not keep110inventing fixes indefinitely, send the user back to the official docs and111explain that this path is still under investigation112- Keep dev and prod tenants separate if the project uses different Auth0113environments114- Do not confuse "Auth0 login works" with "Convex can validate the Auth0 token".115Both need to work.116- If the repo already uses Auth0, preserve existing redirect and tenant117configuration unless the user asked to change it.118- Do not assume the local Auth0 tenant settings match production. Verify the119production domain, client ID, and callback URLs separately.120- For local dev, make sure the Auth0 app settings match the app's real local121port for callback URLs, logout URLs, and web origins122123## Production124125- Ask whether the user wants dev-only setup or production-ready setup126- If the answer is production-ready, make sure the production Auth0 tenant127values, callback URLs, and Convex deployment config are all covered128- Verify production environment variables and redirect settings before calling129the task complete130- Do not silently write a notes file into the repo by default. If the user wants131rollout or handoff docs, create one explicitly.132133## Validation134135- Verify the user can complete the Auth0 login flow136- Verify Convex-authenticated UI renders only after Convex auth state is ready137- Verify protected Convex queries succeed after login138- Verify `ctx.auth.getUserIdentity()` is non-null in protected backend functions139- Verify the Auth0 app settings match the real local callback and logout URLs140during development141- If the Auth0 refresh-token path fails, mark the setup as not fully validated142and direct the user to the official docs instead of claiming the skill143completed successfully144- If production-ready setup was requested, verify the production Auth0145configuration is also covered146147## Checklist148149- [ ] Confirm the user wants Auth0150- [ ] Ask whether the user wants local-only setup or production-ready setup151- [ ] Complete the relevant Auth0 frontend setup152- [ ] Configure `convex/auth.config.ts`153- [ ] Set environment variables154- [ ] Verify Convex authenticated state after login, or explicitly tell the user155this path is still under investigation and send them to the official docs156- [ ] If requested, configure the production deployment too157