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/change-email

Change Email

better-auth-ui/change-email
FreeComponent

A form component for changing the user's email address with verification.

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/change-email.json

Source

src/components/auth/settings/account/change-email.tsxbetter-auth-ui.com/r/change-email.json
1"use client"
2
3import { getViewURL } from "@better-auth-ui/core"
4import { useAuth, useChangeEmail, useSession } from "@better-auth-ui/react"
5import { type SyntheticEvent, useState } from "react"
6import { toast } from "sonner"
7
8import { Button } from "@/components/ui/button"
9import { Card, CardContent, CardFooter } from "@/components/ui/card"
10import { Field, FieldError, FieldLabel } from "@/components/ui/field"
11import { Input } from "@/components/ui/input"
12import { Skeleton } from "@/components/ui/skeleton"
13import { Spinner } from "@/components/ui/spinner"
14import { cn } from "@/lib/utils"
15
16export type ChangeEmailProps = {
17 className?: string
18}
19
20/**
21 * Render a card containing a form to view and update the authenticated user's email.
22 *
23 * Shows a loading skeleton until session data is available, displays the current
24 * email as the form's default value, and sends a verification email to the
25 * new address upon successful submission.
26 *
27 * @returns A JSX element rendering the change-email card and form
28 */
29export function ChangeEmail({ className }: ChangeEmailProps) {
30 const { authClient, basePaths, baseURL, localization, viewPaths } = useAuth()
31 const { data: session } = useSession(authClient)
32
33 const { mutate: changeEmail, isPending } = useChangeEmail(authClient, {
34 onSuccess: () => toast.success(localization.settings.changeEmailSuccess)
35 })
36
37 const [fieldErrors, setFieldErrors] = useState<{
38 email?: string
39 }>({})
40
41 function handleSubmit(e: SyntheticEvent<HTMLFormElement>) {
42 e.preventDefault()
43
44 const formData = new FormData(e.currentTarget)
45 changeEmail({
46 newEmail: formData.get("email") as string,
47 callbackURL: getViewURL(
48 baseURL,
49 basePaths.settings,
50 viewPaths.settings.account
51 )
52 })
53 }
54
55 return (
56 <div>
57 <h2 className="text-sm font-semibold mb-3">
58 {localization.settings.changeEmail}
59 </h2>
60
61 <form onSubmit={handleSubmit}>
62 <Card className={cn(className)}>
63 <CardContent className="flex flex-col gap-6">
64 <Field data-invalid={!!fieldErrors.email}>
65 <FieldLabel htmlFor="email">{localization.auth.email}</FieldLabel>
66
67 {session ? (
68 <Input
69 key={session?.user.email}
70 id="email"
71 name="email"
72 type="email"
73 autoComplete="email"
74 defaultValue={session?.user.email}
75// … truncated

What it pulls in

npm packages

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

Other registry items

  • button
  • card
  • field
  • input
  • skeleton
  • sonner
  • spinner

Files it writes

  • src/components/auth/settings/account/change-email.tsx

Facts

Registry
better-auth-ui
Type
registry:component
Access
Free
Files written
1
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