Settings
better-auth-ui/settingsFreeComponent
A unified settings component that renders the appropriate settings view based on path or view prop with tab navigation.
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/settings.jsonSource
1"use client"23import type { SettingsView } from "@better-auth-ui/core"4import { useAuth, useAuthenticate } from "@better-auth-ui/react"5import { Shield, User2 } from "lucide-react"6import { useMemo } from "react"78import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"9import { cn } from "@/lib/utils"10import { AccountSettings } from "./account/account-settings"11import { SecuritySettings } from "./security/security-settings"1213export type SettingsProps = {14 className?: string15 path?: string16 /** @remarks `SettingsView` */17 view?: SettingsView18 hideNav?: boolean19}2021/**22 * Renders the settings UI and activates the appropriate settings view based on `view` or `path`.23 *24 * @param className - Additional CSS class names applied to the root container25 * @param path - Route path used to resolve which settings view to activate when `view` is not provided26 * @param view - Explicit settings view to activate (for example, `"account"` or `"security"`)27 * @param hideNav - When `true`, hides the settings navigation tabs28 * @returns A JSX element rendering the settings layout and the selected settings panel29 */30export function Settings({ className, view, path, hideNav }: SettingsProps) {31 const { authClient, basePaths, localization, viewPaths, plugins, navigate } =32 useAuth()33 useAuthenticate(authClient)3435 if (!view && !path) {36 throw new Error("[Better Auth UI] Either `view` or `path` must be provided")37 }3839 const currentView = useMemo(() => {40 if (view) return view41 if (!path) return undefined4243 const match = [44 viewPaths.settings,45 ...plugins.map((plugin) => plugin.viewPaths?.settings)46 ]47 .flatMap((source) => Object.entries(source ?? {}))48 .find(([, segment]) => segment === path)4950 return match?.[0] as SettingsView | undefined51 }, [view, path, viewPaths.settings, plugins])5253 if (!currentView) {54 const validPaths = [55 viewPaths.settings,56 ...plugins.map((plugin) => plugin.viewPaths?.settings)57 ]58 .flatMap((source) => Object.values(source ?? {}))59 .join(", ")60 throw new Error(61 `[Better Auth UI] Unknown settings path "${path}". Valid paths are: ${validPaths}`62 )63 }6465 return (66 <Tabs67 value={currentView}68 className={cn("w-full gap-4 md:gap-6", className)}69 >70 <div className={cn(hideNav && "hidden")}>71 <TabsList aria-label={localization.settings.settings}>72 <TabsTrigger73 value="account"74// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from better-auth-ui
All 49 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Account Settingsaccount-settings | better-auth-ui | Components | Free | 2 deps | |
| Active Sessionsactive-sessions | better-auth-ui | Components | Free | 5 deps · 2 files | |
| Additional Fieldadditional-field | better-auth-ui | Components | Free | 5 deps | |
| Adminadmin | better-auth-ui | Components | Free | 4 deps · 3 files | |
| Anonymousanonymous | better-auth-ui | Components | Free | 4 deps · 3 files | |
| API Keyapi-key | better-auth-ui | Components | Free | 4 deps · 10 files | |
| Authauth | better-auth-ui | Components | Free | 2 deps | |
| Auth Providerauth-provider | better-auth-ui | Components | Free | 4 deps · 2 files |
