react-auth-otp
Skill0 starsChanged 21 days agoMITView on GitHub
Canonical front-end authentication for the house stack — Zustand auth store with email+OTP login, optional password login, magic-link auto-verify, refresh tokens, password reset, and an AuthGuard for protected routes. Use this when adding login/registration to a React app, building or fixing an auth store, wiring OTP or magic-link flows, protecting routes, or when a project's auth diverges from the standard — even if the user just says "add user accounts".
In this repository7 other files it gives its agents.
- deploy-cloudrunSkill
- gcp-bootstrapSkill
- gcp-migrate-dataSkill
- react-api-clientSkill
- react-app-scaffoldSkill
- react-seo-ssgSkill
- stack-auditSkill
The file
Files
React auth: OTP + magic link + JWT (house stack)
The front half of the house auth vertical, extracted from perfect-resume (the superset
implementation; brandician lacks password login/reset, wine-your-sign lacks refresh).
Works against the standard FastAPI backend (auth.py + OTP modules — still
project-embedded; the JWT/OTP endpoints are identical across the sibling projects).
Files (assets/)
| File | Copy to | Role |
auth.ts | src/store/auth.ts | Zustand store, persisted to localStorage. Actions: register, login (→ otp_id), loginWithPassword, verifyOTP(otpId, code), verifyMagicLink(token), requestPasswordReset, confirmPasswordReset, confirmPasswordResetMagic, logout |
AuthGuard.tsx | src/components/auth/AuthGuard.tsx | Route wrapper: renders children when authenticated, spinner while loading, redirect to /login otherwise |
Requires the react-api-client skill first — the store calls its auth.* namespace and
formats errors with getErrorMessage(); tokens land in localStorage as
access_token/refresh_token where the client's interceptors expect them.
The flow (backend contract, /api/v1.0)
POST /auth/registeror/auth/login(email) →{otp_id}; an email goes out with a 6-digit code and a magic link (?magic=<token>).POST /auth/verify-otp {otp_id, code}orPOST /auth/magic-link {token}→{access_token, refresh_token}. Login/Register forms auto-callverifyMagicLinkon mount when?magic=is present (spinner → navigate to the app).- Password variants:
/auth/login-password,/auth/password-reset/request,/auth/password-reset/confirm(code) or/confirm-magic(link token). - Token refresh is handled by the api-client interceptor, not the store.
Adaptation points
auth.tspersist key (PROJECT CONFIGmarker) — must be unique per app.AuthGuard.tsxuses the project's Tailwind theme tokens (pr-*in the template) — swap for the project's palette.- Login/Register forms are intentionally not bundled (heavily styled per project);
reference implementations:
perfect-resume/front-end/src/components/auth/LoginForm.tsxandRegisterForm.tsx(captcha, invite codes, waitlist, magic-link auto-verify).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

