# Password reset

> Request a reset email, then choose a new password from the link’s token or an emailed code.

Status: beta. Category: Auth.

```ts
import { ForgotPasswordForm, ResetPasswordForm } from '@glyphui/auth/ui'
```

Exports: `ForgotPasswordForm`, `ResetPasswordForm`.

## Notes

- The confirmation never says whether an account exists, so emails can’t be probed.
- On your reset page, read the token from the URL: <ResetPasswordForm token={params.get("token")} />.
- For code-based backends (Clerk), ForgotPasswordForm continues straight to a code and new-password form.
- A hidden username field helps password managers update the right saved login.

## ResetPasswordForm props

| Prop | Type | Default | Description |
|---|---|---|---|
| `className` | `string` |  |  |
| `description` | `ReactNode` |  |  |
| `email` | `string` |  | For code-based resets: the address the code went to. Shows a code field. |
| `footer` | `ReactNode` |  |  |
| `headingLevel` | `HeadingLevel` |  | Heading level of the title. Default 1, for a page whose main content is the form. |
| `minPasswordLength` | `number` | `8` |  |
| `onSuccess` | `(() => void)` |  | Called after the password changes. |
| `signInHref` | `string` |  | Adds "Back to sign in" and the success screen's button. |
| `title` | `ReactNode` | `Choose a new password` |  |
| `token` | `string` |  | The token from the reset link, usually read from the URL. |

## Example: Forgot, then reset

Request a reset for ada@example.com; the toast shows the link token, which this demo passes straight to the reset form.

```tsx
import { AuthProvider } from '@glyphui/auth'
import { memoryAdapter } from '@glyphui/auth/memory'
import { ForgotPasswordForm, ResetPasswordForm } from '@glyphui/auth/ui'
import { Button, toast } from '@glyphui/ui'
import { useState } from 'react'

export default function Example() {
  const [token, setToken] = useState<string | null>(null)
  const [adapter] = useState(() =>
    memoryAdapter({
      latency: 400,
      users: [{ email: 'ada@example.com', password: 'correct horse' }],
      onCode: ({ kind, code }) => {
        if (kind !== 'reset-password') return
        toast('Reset email sent', { description: 'Opening the link for you…' })
        setToken(code)
      },
    }),
  )
  return (
    <AuthProvider adapter={adapter} syncTabs={false}>
      <div className="grid w-full justify-items-center gap-3">
        {token ? (
          <>
            <ResetPasswordForm headingLevel={3} token={token} />
            <Button variant="ghost" size="sm" onClick={() => setToken(null)}>
              Start over
            </Button>
          </>
        ) : (
          <ForgotPasswordForm headingLevel={3} defaultEmail="ada@example.com" />
        )}
      </div>
    </AuthProvider>
  )
}
```

Live page: https://glyphui.xyz/components/password-reset
