SignInForm
The whole sign-in flow in one component: password, OAuth, email link, and the code steps the backend asks for.
Status: beta. Category: Auth.
import { SignInForm, MagicLinkSent } from '@glyphui/auth/ui'
Exports: SignInForm, MagicLinkSent.
Notes
- OAuth buttons appear for every provider the adapter supports; pass providers={[]} to hide them.
- Passwords and emails use autocomplete hints so password managers fill and save them.
- onSuccess runs once the user is fully signed in; with React Router, pass useRedirectAfterSignIn().
- Errors with fieldErrors show next to the field; anything else shows above the form.
SignInForm props
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | ||
defaultEmail | string | ||
description | ReactNode | Sign in to continue. | |
footer | ReactNode | ||
forgotPasswordHref | string | Adds a "Forgot password?" link beside the password label. | |
headingLevel | HeadingLevel | Heading level of the title. Default 1, for a page whose main content is the form. | |
magicLink | boolean | true | Offer "Email me a sign-in link" when the adapter supports it. Default true. |
onSuccess | ((session: AuthSession) => void) | Called once the user is fully signed in (after any code steps). | |
providers | readonly OAuthProvider[] | OAuth buttons to show. Default: every provider the adapter supports; [] for none. | |
signUpHref | string | Adds "New here? Create an account" linking here. | |
title | ReactNode | Welcome back | |
twoFactor | { title?: ReactNode; description?: ReactNode; } | Wording for the two-step code screen. By default it follows how the server sends codes. |
Example: Sign in
[email protected] / correct horse signs in; a wrong password shows the server’s message. Codes appear as toasts.
import { AuthProvider } from '@glyphui/auth'
import { memoryAdapter } from '@glyphui/auth/memory'
import { SignInForm } from '@glyphui/auth/ui'
import { toast } from '@glyphui/ui'
const adapter = memoryAdapter({
latency: 500,
oauthProviders: ['google', 'github'],
users: [{ email: '[email protected]', password: 'correct horse', name: 'Ada Lovelace' }],
})
export default function Example() {
return (
<AuthProvider adapter={adapter} syncTabs={false}>
<SignInForm
headingLevel={3}
magicLink={false}
signUpHref="#sign-up"
forgotPasswordHref="#forgot-password"
onSuccess={(session) => toast.success(`Signed in as ${session.user.name}`)}
/>
</AuthProvider>
)
}
Example: Two-step and email links
[email protected] / cobol rules continues to a code. "Email me a sign-in link" switches to passwordless.
import { AuthProvider } from '@glyphui/auth'
import { memoryAdapter } from '@glyphui/auth/memory'
import { SignInForm } from '@glyphui/auth/ui'
import { toast } from '@glyphui/ui'
const adapter = memoryAdapter({
latency: 500,
oauthProviders: [],
users: [
{ email: '[email protected]', password: 'cobol rules', name: 'Grace Hopper', twoFactor: true },
],
onCode: ({ email, code }) => toast(`Email to ${email}`, { description: `Your code: ${code}` }),
})
export default function Example() {
return (
<AuthProvider adapter={adapter} syncTabs={false}>
<SignInForm
headingLevel={3}
onSuccess={(session) => toast.success(`Signed in as ${session.user.name}`)}
/>
</AuthProvider>
)
}
Live page: https://glyphui.xyz/components/sign-in-form