Admin
better-auth-ui/adminFreeComponent
Admin plugin integration that adds a stop-impersonating action to the user button while an administrator is impersonating another user.
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/admin.jsonSource
1"use client"23import { isImpersonatingSession } from "@better-auth-ui/core/plugins"4import {5 type AdminAuthClient,6 useAuth,7 useAuthPlugin,8 useSession,9 useStopImpersonating10} from "@better-auth-ui/react"11import { UserRoundCheck } from "lucide-react"1213import { DropdownMenuItem } from "@/components/ui/dropdown-menu"14import { Spinner } from "@/components/ui/spinner"15import { adminPlugin } from "@/lib/auth/admin-plugin"1617export type StopImpersonatingProps = {18 className?: string19}2021/**22 * Restore the administrator's session when the current session is23 * impersonating another user.24 */25export function StopImpersonating({ className }: StopImpersonatingProps) {26 const { authClient } = useAuth()27 const { localization } = useAuthPlugin(adminPlugin)28 const { data: session } = useSession(authClient)29 const stopImpersonating = useStopImpersonating(authClient as AdminAuthClient)3031 if (!isImpersonatingSession(session)) {32 return null33 }3435 return (36 <DropdownMenuItem37 className={className}38 disabled={stopImpersonating.isPending}39 onClick={() => stopImpersonating.mutate(undefined)}40 >41 {stopImpersonating.isPending ? (42 <Spinner />43 ) : (44 <UserRoundCheck className="text-muted-foreground" />45 )}4647 {localization.stopImpersonating}48 </DropdownMenuItem>49 )50}
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 | |
| 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 | |
| Auth Redirectauth-redirect | better-auth-ui | Components | Free | 3 deps |
