Electron Clerk Auth
Use this skill for any auth work that touches:
apps/electronClerk session setup or GitHub connect UIapps/marketing/app/auth/electronsign-in token issuanceconvexauth provider or GitHub token access- packaged Electron auth failures that do not reproduce on localhost
- Clerk production configuration questions for
clerk.hypercoder.app
Workflow
- Identify the failing layer before editing anything. Electron UI entrypoints, Electron main process, marketing auth page, Convex backend, or Clerk dashboard/config.
- Read the right reference file.
references/architecture.mdfor end-to-end flow and file ownership.references/production-setup.mdfor env vars, Clerk dashboard requirements, and cross-service invariants.references/debugging.mdfor symptom-based diagnosis and validation steps. - Preserve the current architecture unless you have a strong reason to change it. Packaged Electron auth is not standard web Clerk auth. It relies on a localhost callback server, a sign-in token minted on the marketing app, renderer ticket consumption, and a main-process HTTPS fetch proxy for Clerk FAPI requests.
- Validate at the right level.
For code-only changes, run Electron typecheck and targeted tests first.
For transport or auth-init changes, also run
pnpm --filter @hypersurge/electron build:ci. For production-only fixes, prefer a real packaged auth smoke test before declaring success.
Non-Negotiable Invariants
- Electron does not start GitHub OAuth with
authenticateWithRedirectinside the renderer. It opens the system browser to the marketing auth page. - The marketing auth page is responsible for the normal web Clerk login and for minting the Clerk
sign_in_token. - Electron consumes that token with
signIn.create({ strategy: "ticket", ticket }). - Packaged Electron Clerk HTTPS requests are proxied through Electron main to avoid renderer CORS failures.
- Convex must trust the same Clerk issuer domain that the marketing app and Electron build are using.
- Treat Clerk
__unstable__hooks in Electron as pinned implementation details. Re-verify them on Clerk upgrades.
Key Files
apps/electron/src/main.tsxapps/electron/src/lib/auth.tsapps/electron/src/lib/clerkElectron.tsapps/electron/src/lib/clerkElectronFetch.tsapps/electron/src/hooks/useAuthDeepLink.tsapps/electron/electron/main.tsapps/electron/electron/preload.tsapps/marketing/app/auth/electron/page.tsxapps/marketing/app/auth/electron/actions.tsconvex/auth.config.tsconvex/github.ts
Validation Commands
For Electron-only changes:
pnpm --filter @hypersurge/electron typecheck
pnpm --filter @hypersurge/electron exec vitest run src/__tests__/lib/clerkElectronFetch.test.ts
pnpm --filter @hypersurge/electron build:ci
For marketing auth page changes:
pnpm --filter @hypersurge/marketing build
# Then test the full browser -> Electron sign-in flow
For Convex auth config changes:
npx convex deploy # or convex dev for local
# Verify Clerk issuer domain and secret key match production
If the touched layer is outside Electron (marketing or Convex), validate cross-service by running the full packaged sign-in flow — Electron typecheck alone won't catch mismatched keys or issuer domains.
If the issue is production-only, do not stop at unit/build validation. Run a packaged Electron sign-in smoke test.