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/magic-link

Magic Link

better-auth-ui/magic-link
FreeComponent

Magic-link plugin: passwordless email sign-in form, toggle button between password and magic-link routes, and the AuthPlugin scaffolding that registers the view with `<Auth>`.

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/magic-link.json

Source

src/components/auth/magic-link.tsxbetter-auth-ui.com/r/magic-link.json · first 6 KB
1"use client"
2
3import { authMutationKeys } from "@better-auth-ui/core"
4import {
5 type MagicLinkAuthClient,
6 useAuth,
7 useAuthPlugin,
8 useSignInMagicLink
9} from "@better-auth-ui/react"
10import { useIsMutating } from "@tanstack/react-query"
11import { type SyntheticEvent, useState } from "react"
12
13import { Button } from "@/components/ui/button"
14import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
15import {
16 Field,
17 FieldDescription,
18 FieldError,
19 FieldGroup,
20 FieldLabel,
21 FieldSeparator
22} from "@/components/ui/field"
23import { Input } from "@/components/ui/input"
24import { Spinner } from "@/components/ui/spinner"
25import { magicLinkPlugin } from "@/lib/auth/magic-link-plugin"
26import { cn } from "@/lib/utils"
27import { MAGIC_LINK_SENT_STORAGE_KEY } from "./magic-link-sent"
28import { ProviderButtons, type SocialLayout } from "./provider-buttons"
29
30export type MagicLinkProps = {
31 className?: string
32 socialLayout?: SocialLayout
33 socialPosition?: "top" | "bottom"
34}
35
36/**
37 * Render a card-based sign-in form that sends an email magic link and optionally shows social provider buttons.
38 *
39 * @param className - Additional CSS class names applied to the card container
40 * @param socialLayout - Layout style for social provider buttons
41 * @param socialPosition - Position of social provider buttons; `"top"` or `"bottom"`. Defaults to `"bottom"`.
42 * @returns The magic-link sign-in UI as a JSX element
43 */
44export function MagicLink({
45 className,
46 socialLayout,
47 socialPosition = "bottom"
48}: MagicLinkProps) {
49 const {
50 authClient,
51 basePaths,
52 baseURL,
53 emailAndPassword,
54 localization,
55 navigate,
56 plugins,
57 redirectTo,
58 socialProviders,
59 viewPaths,
60 Link
61 } = useAuth()
62 const { localization: magicLinkLocalization, viewPaths: magicLinkViewPaths } =
63 useAuthPlugin(magicLinkPlugin)
64
65 const [email, setEmail] = useState("")
66
67 const { mutate: signInMagicLink, isPending: signInMagicLinkPending } =
68 useSignInMagicLink(authClient as MagicLinkAuthClient, {
69 onSuccess: (_data, variables) => {
70 sessionStorage.setItem(MAGIC_LINK_SENT_STORAGE_KEY, variables.email)
71 navigate({
72 to: `${basePaths.auth}/${magicLinkViewPaths.auth.magicLinkSent}`
73 })
74 }
75 })
76
77 const signInMutating = useIsMutating({
78 mutationKey: authMutationKeys.signIn.all
79 })
80 const signUpMutating = useIsMutating({
81 mutationKey: authMutationKeys.signUp.all
82 })
83// … truncated

What it pulls in

npm packages

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

Other registry items

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

Files it writes

  • src/lib/auth/auth-plugin.ts
  • src/lib/auth/magic-link-plugin.ts
  • src/components/auth/magic-link.tsx
  • src/components/auth/magic-link-sent.tsx
  • src/components/auth/magic-link-button.tsx
  • src/components/auth/provider-button.tsx
  • src/components/auth/provider-buttons.tsx
  • src/components/auth/open-email-button.tsx
  • src/components/auth/use-is-hydrated.ts
  • src/components/auth/last-login-method/last-used-badge.tsx

Facts

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