Password reset

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

Status: beta. Category: Auth.

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

PropTypeDefaultDescription
classNamestring
descriptionReactNode
emailstringFor code-based resets: the address the code went to. Shows a code field.
footerReactNode
headingLevelHeadingLevelHeading level of the title. Default 1, for a page whose main content is the form.
minPasswordLengthnumber8
onSuccess(() => void)Called after the password changes.
signInHrefstringAdds "Back to sign in" and the success screen's button.
titleReactNodeChoose a new password
tokenstringThe token from the reset link, usually read from the URL.

Example: Forgot, then reset

Request a reset for [email protected]; the toast shows the link token, which this demo passes straight to the reset form.

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: '[email protected]', 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="[email protected]" />
        )}
      </div>
    </AuthProvider>
  )
}

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