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-avatar

User Avatar

better-auth-ui/user-avatar
FreeComponent

Renders the current user's avatar using session data. Shows a skeleton while loading and falls back to initials when no image is available.

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-avatar.json

Source

src/components/auth/user/user-avatar.tsxbetter-auth-ui.com/r/user-avatar.json
1"use client"
2
3import {
4 type UsernameAuthClient,
5 useAuth,
6 useSession
7} from "@better-auth-ui/react"
8import type { User } from "better-auth"
9import { User2 } from "lucide-react"
10import type { ReactNode } from "react"
11
12import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
13import { Skeleton } from "@/components/ui/skeleton"
14import { cn } from "@/lib/utils"
15
16export type UserAvatarProps = {
17 className?: string
18 fallback?: ReactNode
19 isPending?: boolean
20 /** @remarks `User` */
21 user?: User & { username?: string | null; displayUsername?: string | null }
22}
23
24/**
25 * Display a user's avatar using session information or an explicit user prop.
26 *
27 * Renders a circular avatar that shows the user's image when available, a fallback node if provided, or the user's first two initials; while the session is loading (or when `isPending` is true) and no `user` prop is supplied, renders a skeleton placeholder.
28 *
29 * @param className - Additional CSS classes applied to the avatar container
30 * @param user - Optional user object to display instead of the session user
31 * @param isPending - When true, treat the component as loading and show the skeleton if no `user` is provided
32 * @param fallback - Node to render inside the avatar fallback area before initials or the default icon
33 * @returns The avatar element to render (JSX)
34 */
35export function UserAvatar({
36 className,
37 user,
38 isPending,
39 fallback
40}: UserAvatarProps) {
41 const { authClient } = useAuth()
42 const { data: session, isPending: sessionPending } = useSession(
43 authClient as UsernameAuthClient,
44 { enabled: !user && !isPending }
45 )
46
47 if ((isPending || sessionPending) && !user) {
48 return <Skeleton className={cn("size-8 rounded-full", className)} />
49 }
50
51 const resolvedUser = user ?? session?.user
52
53 const initials = (
54 resolvedUser?.username ||
55 resolvedUser?.name ||
56 resolvedUser?.email
57 )
58 ?.slice(0, 2)
59 .toUpperCase()
60
61 return (
62 <Avatar
63 className={cn(
64 "size-8 bg-muted text-foreground text-sm rounded-full",
65 className
66 )}
67 >
68 <AvatarImage
69 src={resolvedUser?.image ?? undefined}
70 alt={
71 resolvedUser?.displayUsername ||
72 resolvedUser?.name ||
73 resolvedUser?.email
74 }
75 />
76
77 <AvatarFallback className="text-muted-foreground!">
78 {fallback || initials || <User2 className="size-4" />}
79 </AvatarFallback>
80 </Avatar>
81 )
82}

What it pulls in

npm packages

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

Other registry items

  • avatar
  • skeleton

Files it writes

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

Facts

Registry
better-auth-ui
Type
registry:component
Access
Free
Files written
1
Licence
MIT
In the index
at or before 2026-08-12
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

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex