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/user-button

User Button

better-auth-ui/user-button
FreeComponent

Renders a user button with dropdown menu showing user info, settings link, plugin-contributed menu items (e.g. theme toggle, account switcher), and sign-in/sign-out actions.

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/user-button.json

Source

src/components/auth/user/user-button.tsxbetter-auth-ui.com/r/user-button.json · first 6 KB
1"use client"
2
3import {
4 type MultiSessionAuthClient,
5 useAuth,
6 useSession,
7 useSetActiveSession
8} from "@better-auth-ui/react"
9import {
10 ChevronsUpDown,
11 LogIn,
12 LogOut,
13 Settings,
14 UserPlus2
15} from "lucide-react"
16import { isValidElement, type ReactElement, type ReactNode } from "react"
17
18import { buttonVariants } from "@/components/ui/button"
19import {
20 DropdownMenu,
21 DropdownMenuContent,
22 DropdownMenuGroup,
23 DropdownMenuItem,
24 DropdownMenuLabel,
25 DropdownMenuSeparator,
26 DropdownMenuTrigger
27} from "@/components/ui/dropdown-menu"
28import { cn } from "@/lib/utils"
29import { UserAvatar } from "./user-avatar"
30import { UserView } from "./user-view"
31
32/** Auth states a `UserButton` link can be visible in. */
33export type UserButtonLinkVisibility =
34 | "authenticated"
35 | "unauthenticated"
36 | "always"
37
38/** A simple link entry rendered as a `DropdownMenuItem` in the `UserButton` menu. */
39export type UserButtonLink = {
40 /** Visible label. */
41 label: ReactNode
42 /** Destination URL. */
43 href: string
44 /** Optional leading icon. Sized/coloured to match built-in items. */
45 icon?: ReactNode
46 /** Forwarded to the underlying `DropdownMenuItem`. */
47 variant?: "default" | "destructive"
48 /**
49 * When this link is visible based on auth state.
50 * @default "always"
51 */
52 visibility?: UserButtonLinkVisibility
53}
54
55export type UserButtonProps = {
56 className?: string
57 align?: "center" | "end" | "start" | undefined
58 sideOffset?: number
59 size?: "default" | "icon"
60 variant?:
61 | "default"
62 | "destructive"
63 | "ghost"
64 | "link"
65 | "outline"
66 | "secondary"
67 /** Additional menu entries rendered above the built-in items. */
68 links?: (UserButtonLink | ReactElement)[]
69 /** Hide the built-in "Settings" link. Useful when replacing it via `links`. */
70 hideSettings?: boolean
71}
72
73function renderUserLink(
74 link: UserButtonLink | ReactElement,
75 navigate: (options: { to: string; replace?: boolean }) => void,
76 fallbackKey: string
77): ReactNode {
78 if (isValidElement(link)) return link
79
80 const { label, href, icon, variant } = link
81 return (
82 <DropdownMenuItem
83 key={fallbackKey}
84 variant={variant}
85 onClick={() => navigate({ to: href })}
86 >
87 {icon}
88 {label}
89 </DropdownMenuItem>
90 )
91}
92
93/**
94 * Render a user dropdown button that shows user info, settings, theme controls, and authentication actions.
95 *
96 * Includes user profile, settings link, optional multi-session account switching, theme picker,
97// … 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
  • dropdown-menu
  • spinner
  • https://better-auth-ui.com/r/radix-nova/user-view.json

Files it writes

  • src/components/auth/user/user-button.tsx

Facts

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

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