AuthForm
The web sign-in form. See the file's header. ```tsx const client = createAuthFormClient(supabase, { url, publishableKey, redirectTo: `${origin}/auth/callback` }); <AuthPage branding={{ headline: messages.auth.titles[mode] }}> <AuthForm client={client} mode={mode} onModeChange={setMode} methods={["password", "email-code"]} onSuccess={() => navigate("/")} /> </AuthPage> ```
packages/ui/src/components/patterns/auth-form.tsx
@marktiderman/genesis-ui/patternsimport { AuthForm } from "@marktiderman/genesis-ui/patterns";react-docgen-typescript.AuthForm
The web sign-in form. See the file's header. ```tsx const client = createAuthFormClient(supabase, { url, publishableKey, redirectTo: `${origin}/auth/callback` }); <AuthPage branding={{ headline: messages.auth.titles[mode] }}> <AuthForm client={client} mode={mode} onModeChange={setMode} methods={["password", "email-code"]} onSuccess={() => navigate("/")} /> </AuthPage> ```
| Prop | Type | Default | Description |
|---|---|---|---|
| client* | AuthFormClient | — | Every call goes through it. |
| allowPasswordReset | boolean | true | Offer "Forgot password?" with the password method. Default true. |
| allowSignUp | boolean | true | Offer "Create one", and let a magic link or code make an account. Default true. |
| className | string | — | |
| codeLength | number | 6 | Digits in an emailed code. Default 6 (Supabase's default). It must match the project's `otp_length` (Auth settings, "Email OTP length"): the code field takes exactly this many digits, so with a mismatch no code can ever be entered whole and code sign-in fails with nothing to say why. `/auth/v1/settings` doesn't report `otp_length`, so the form can't check it. |
| defaultMode | enum | sign-in | The first mode, uncontrolled. Default `"sign-in"`. |
| initialEmail | string | Initial email ("sign in as …" links). In `mode="new-password"`, the account's email, when the client can't say (`currentEmail`). | |
| methods | readonly AuthSignInMethod[] | ["password"] | How to sign in, in order: the first is shown, the rest are links under the form. Default `["password"]`. |
| minPasswordLength | number | 8 | For a new password. Default 8. Supabase Auth still applies its own rules. |
| mode | enum | — | The mode, controlled. Pair with `onModeChange` (a route per mode, say). |
| notice | string | AuthFormNotice | null | — | A notice above the form, on its first step: why the person is here again ("your reset link has expired", "sign-in was cancelled", "your account is deleted"). A string is a message on its own. Read it from the URL the callback sent them to, say. |
| offerCodeOnConfirm | boolean | false | Opt-in: on the "check your email" screens after a magic link and after sign-up, offer "Enter the code instead", which opens the code step for the same email. For someone signing in from an embedded browser (an in-app web view), where the link opens in another browser and they would be stuck. Needs `"email-code"` in `methods` and `{{ .Token }}` in the project's Magic Link and Confirm signup email templates. Default false. |
| onModeChange | ((mode: AuthFormMode) => void) | — | The form's links ("Create one", "Forgot password?", "Back to sign in") ask for a mode. |
| onSuccess | ((result: AuthFormSuccess) => void) | — | Signed in, signed up with a session, or a new password saved. Navigate from here. |
| providers | false | readonly (string | AuthFormProvider)[] | — | Provider buttons. Ids or objects; `false` for none. Left out, the form asks `client.providers()` (with Supabase: the providers turned on in the project). |
| resendCooldown | number | 60 | Seconds before a code can be sent again. Default 60 (Supabase's default rate limit). |
| showAccountEmail | boolean | false | Opt-in: in `mode="new-password"`, show the account's email read-only above the new password. Without it the email (when known, from `initialEmail` or `client.currentEmail()`) is still in the form, hidden, with `autocomplete="username"`, so a password manager saves the pair. Default false. |
| signUpFields | readonly AuthFormSignUpFieldSpec[] | ((slot: AuthFormSignUpFieldsSlot) => ReactNode) | — | Opt-in: more fields on the sign-up form, above the email, whose values go to `client.signUp` as `data` (with Supabase, `options.data`: the user's metadata, which an app's signup trigger reads as `full_name`, say). Named fields (`["full_name"]`, or your own), or a slot that draws its own inputs and sets the values. Default none, and `signUp` gets no `data`. |
| testID | string | auth-form | Default `"auth-form"`; parts use `${testID}-email`, `-phone`, `-password`, `-submit`, `-error`, `-status`, `-notice`, `-code`, `-resend`, `-enter-code`, `-provider-<id>`, `-field-<name>`, `-account-email`. |
AUTH_PROVIDER_NAMES
Brand names for provider ids Supabase Auth knows. Not translated.
No declared props.