Sign Out
better-auth-ui/sign-outFreeComponent
A component that signs the user out when mounted and displays a loading state.
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/sign-out.jsonSource
1"use client"23import { useAuth, useSignOut } from "@better-auth-ui/react"4import { useEffect, useRef } from "react"5import { Spinner } from "@/components/ui/spinner"6import { cn } from "@/lib/utils"78export type SignOutProps = {9 className?: string10}1112/**13 * Signs the current user out on mount and renders a centered spinner while the operation completes.14 *15 * @param className - Optional additional class names appended to the root element16 * @returns The spinner shown during sign-out17 */18export function SignOut({ className }: SignOutProps) {19 const { authClient, basePaths, navigate, viewPaths } = useAuth()2021 const { mutate: signOut } = useSignOut(authClient, {22 onError: () => {23 navigate({24 to: `${basePaths.auth}/${viewPaths.auth.signIn}`,25 replace: true26 })27 },28 onSuccess: () =>29 navigate({30 to: `${basePaths.auth}/${viewPaths.auth.signIn}`,31 replace: true32 })33 })3435 const hasSignedOut = useRef(false)3637 useEffect(() => {38 if (hasSignedOut.current) return39 hasSignedOut.current = true4041 signOut()42 }, [signOut])4344 return <Spinner className={cn("mx-auto my-auto", className)} />45}
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 |
