BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/better-auth-ui/forgot-password

Forgot Password

better-auth-ui/forgot-password
FreeComponent

A form component for requesting a password reset link via email.

Live preview

live · rendered by the registry
Rendered by better-auth-ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://better-auth-ui.com/r/forgot-password.json

Source

src/components/auth/forgot-password.tsxbetter-auth-ui.com/r/forgot-password.json
1"use client"
2
3import { getViewURL } from "@better-auth-ui/core"
4import {
5 useAuth,
6 useFetchOptions,
7 useRequestPasswordReset
8} from "@better-auth-ui/react"
9import { type SyntheticEvent, useState } from "react"
10
11import { Button } from "@/components/ui/button"
12import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
13import {
14 Field,
15 FieldDescription,
16 FieldError,
17 FieldGroup,
18 FieldLabel
19} from "@/components/ui/field"
20import { Input } from "@/components/ui/input"
21import { Spinner } from "@/components/ui/spinner"
22import { cn } from "@/lib/utils"
23import { RESET_LINK_SENT_STORAGE_KEY } from "./reset-link-sent"
24
25export type ForgotPasswordProps = {
26 className?: string
27}
28
29/**
30 * Render a card-based "Forgot Password" form that sends a password-reset email.
31 *
32 * The form displays an email input, submit button, and a link back to sign-in.
33 * After a successful request the submitted email is stored in `sessionStorage`
34 * and the user is redirected to the reset-link-sent view, which offers to open
35 * their email provider.
36 *
37 * @param className - Optional additional CSS class names applied to the card
38 * @returns The forgot-password form UI as a JSX element
39 */
40export function ForgotPassword({ className }: ForgotPasswordProps) {
41 const {
42 authClient,
43 baseURL,
44 basePaths,
45 localization,
46 navigate,
47 plugins,
48 viewPaths,
49 Link
50 } = useAuth()
51
52 const { fetchOptions, resetFetchOptions } = useFetchOptions()
53
54 const { mutate: requestPasswordReset, isPending } = useRequestPasswordReset(
55 authClient,
56 {
57 onError: () => {
58 resetFetchOptions()
59 },
60 onSuccess: (_data, { email }) => {
61 sessionStorage.setItem(RESET_LINK_SENT_STORAGE_KEY, email)
62 navigate({ to: `${basePaths.auth}/${viewPaths.auth.resetLinkSent}` })
63 }
64 }
65 )
66
67 function handleSubmit(e: SyntheticEvent<HTMLFormElement>) {
68 e.preventDefault()
69 const formData = new FormData(e.currentTarget)
70 requestPasswordReset({
71 email: formData.get("email") as string,
72 redirectTo: getViewURL(
73 baseURL,
74 basePaths.auth,
75 viewPaths.auth.resetPassword
76 ),
77 fetchOptions
78 })
79 }
80
81 const Captcha = plugins.find(
82 (plugin) => plugin.captchaComponent
83 )?.captchaComponent
84
85 const [fieldErrors, setFieldErrors] = useState<{
86 email?: string
87 }>({})
88
89 return (
90 <Card className={cn("w-full max-w-sm", className)}>
91 <CardHeader>
92// … truncated

What it pulls in

npm packages

  • @better-auth-ui/react@latest
  • @better-auth-ui/core@latest
  • better-auth
  • lucide-react

Other registry items

  • button
  • card
  • input
  • field
  • sonner
  • spinner
  • tooltip

Files it writes

  • src/components/auth/forgot-password.tsx
  • src/components/auth/reset-link-sent.tsx
  • src/components/auth/open-email-button.tsx
  • src/components/auth/use-is-hydrated.ts

Facts

Registry
better-auth-ui
Type
registry:component
Access
Free
Files written
4
Licence
MIT
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on better-auth-ui better-auth-ui.com better-auth-ui/better-auth-ui on GitHub Raw registry item This item as JSON

More from better-auth-ui

All 49 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Account Settingsaccount-settingsbetter-auth-uiComponentsFree2 deps
Active Sessionsactive-sessionsbetter-auth-uiComponentsFree5 deps · 2 files
Additional Fieldadditional-fieldbetter-auth-uiComponentsFree5 deps
Adminadminbetter-auth-uiComponentsFree4 deps · 3 files
Anonymousanonymousbetter-auth-uiComponentsFree4 deps · 3 files
API Keyapi-keybetter-auth-uiComponentsFree4 deps · 10 files
Authauthbetter-auth-uiComponentsFree2 deps
Auth Providerauth-providerbetter-auth-uiComponentsFree4 deps · 2 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex