Interface de connexion React pour Better Auth : connexion avec 2FA, inscription, boutons sociaux et hooks
Code6 fichiersContexte~468 tokensanalyse réussie
Installer
$
genpm add @yohangel/auth-reactCe que vous obtenez
- Source dans src/lib/auth-react/, 6 fichiers. (10,4 ko)
- Règles IA dans src/lib/auth-react/AGENTS.md, plus les fichiers de règles de l’IDE.
README
Ce paquet n’a pas de README.
~468 tokens→ src/lib/auth-react/AGENTS.md→ .cursor/rules/genpm-yohangel-auth-react.mdc
Voici exactement ce que lit votre IA quand elle travaille dans src/lib/auth-react. Rien d’autre n’est ajouté à son contexte.
@yohangel/auth-react — rules for AI agents
Purpose
React client for a server running @yohangel/auth (Next.js, Express, NestJS…): useSession, unstyled accessible forms (sign-in with TOTP second step, sign-up, social buttons) and UI guards. Client-only; it never decides access by itself.
Module map
index.ts— public API.client.ts—authClient(Better Auth React client + 2FA plugin),useSession,signIn,signUp,signOut,AUTH_BASE_URL.forms.tsx—SignInForm,SignUpForm,SocialButtons,defaultLabels/AuthLabels.guard.tsx—SignedIn(render with/without session),SignOutButton.
Integration (do this after installing)
- Same origin as the API (Next.js, or SPA served by the same server): nothing to configure.
- API on another origin: set
AUTH_BASE_URLinclient.tsto the API URL, add this app's origin toAUTH_TRUSTED_ORIGINSon the server, and enable CORS withcredentials: truethere. - Pages:
<SignInForm redirectTo="/dashboard" />,<SignUpForm redirectTo="/welcome" />,<SocialButtons providers={['github']} />(only providers configured on the server). - In Next.js these are Client Components: put
'use client'in the file that renders them. - Translate by passing
labels={{ signIn: '…', password: '…' }}; style viaclassNameand the[data-auth-error]attribute.
Conventions
- Use
useSession()for UI state only (show name, hide buttons). Every protected API/page must check the session on the server. - Keep the password
minLengthin sync with the server (12).
Don't
- Don't store tokens in
localStorage/sessionStorage: the session lives in an HttpOnly cookie managed by Better Auth. - Don't pass absolute URLs from query params to
redirectTo(the components only follow internal paths). - Don't log form values or errors that may contain the password.
# @yohangel/auth-react — rules for AI agents
## Purpose
React client for a server running `@yohangel/auth` (Next.js, Express, NestJS…): `useSession`, unstyled accessible forms (sign-in with TOTP second step, sign-up, social buttons) and UI guards. Client-only; it never decides access by itself.
## Module map
- `index.ts` — public API.
- `client.ts` — `authClient` (Better Auth React client + 2FA plugin), `useSession`, `signIn`, `signUp`, `signOut`, `AUTH_BASE_URL`.
- `forms.tsx` — `SignInForm`, `SignUpForm`, `SocialButtons`, `defaultLabels` / `AuthLabels`.
- `guard.tsx` — `SignedIn` (render with/without session), `SignOutButton`.
## Integration (do this after installing)
1. Same origin as the API (Next.js, or SPA served by the same server): nothing to configure.
2. API on another origin: set `AUTH_BASE_URL` in `client.ts` to the API URL, add this app's origin to `AUTH_TRUSTED_ORIGINS` on the server, and enable CORS with `credentials: true` there.
3. Pages: `<SignInForm redirectTo="/dashboard" />`, `<SignUpForm redirectTo="/welcome" />`, `<SocialButtons providers={['github']} />` (only providers configured on the server).
4. In Next.js these are Client Components: put `'use client'` in the file that renders them.
5. Translate by passing `labels={{ signIn: '…', password: '…' }}`; style via `className` and the `[data-auth-error]` attribute.
## Conventions
- Use `useSession()` for UI state only (show name, hide buttons). Every protected API/page must check the session on the server.
- Keep the password `minLength` in sync with the server (12).
## Don't
- Don't store tokens in `localStorage`/`sessionStorage`: the session lives in an HttpOnly cookie managed by Better Auth.
- Don't pass absolute URLs from query params to `redirectTo` (the components only follow internal paths).
- Don't log form values or errors that may contain the password.
L’arborescence exacte qui sera injectée, après .genpmignore. Épinglée à
// @yohangel/auth-react — cliente de Better Auth para React: hooks, formularios y guardas. Funciona con cualquier
// servidor que monte @yohangel/auth (Next.js, Express, NestJS…).
export { AUTH_BASE_URL, authClient, signIn, signOut, signUp, useSession } from './client.js';
export { type AuthLabels, defaultLabels, SignInForm, SignUpForm, SocialButtons } from './forms.js';
export { SignedIn, SignOutButton } from './guard.js';
Ce paquet ne déclare aucun serveur MCP.
| Version | Commit | Publié | Analyse |
|---|---|---|---|
| 1.0.0 | 7145b9d | il y a 3 heures | ✔ analyse réussie |
- genpm
- aucun
- proposé
- GenPM propose la commande npm et ne l’exécute que si vous acceptez.
- analyse
- analyse réussie · 0 problème
- commit
- auth-react@1.0.0 → 7145b9d58055b5145085782c958b7577f1d65276 · vérifié après téléchargement
- scripts
- Aucun. GenPM n’exécute jamais le code des paquets.
- licence
- MIT
- signalement
- Vous avez repéré un problème ?