Anonymous
better-auth-ui/anonymousFreeComponent
Adds a Continue as guest button backed by Better Auth's anonymous plugin.
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/anonymous.jsonSource
1"use client"23import { authMutationKeys } from "@better-auth-ui/core"4import {5 type AnonymousAuthClient,6 useAuth,7 useAuthPlugin,8 useSignInAnonymous9} from "@better-auth-ui/react"10import { useIsMutating } from "@tanstack/react-query"11import { UserRound } from "lucide-react"1213import { Button } from "@/components/ui/button"14import { Spinner } from "@/components/ui/spinner"15import { anonymousPlugin } from "@/lib/auth/anonymous-plugin"16import { cn } from "@/lib/utils"1718/** Sign in with a temporary anonymous account. */19export function AnonymousButton() {20 const { authClient, navigate, redirectTo } = useAuth()21 const { localization } = useAuthPlugin(anonymousPlugin)22 const { mutate: signInAnonymous, isPending: anonymousPending } =23 useSignInAnonymous(authClient as AnonymousAuthClient, {24 onSuccess: () => navigate({ to: redirectTo })25 })2627 const signInMutating = useIsMutating({28 mutationKey: authMutationKeys.signIn.all29 })30 const signUpMutating = useIsMutating({31 mutationKey: authMutationKeys.signUp.all32 })33 const isPending = signInMutating + signUpMutating > 03435 return (36 <Button37 type="button"38 variant="outline"39 disabled={isPending}40 className={cn("w-full", isPending && "pointer-events-none")}41 onClick={() => signInAnonymous()}42 >43 {anonymousPending ? (44 <Spinner data-icon="inline-start" />45 ) : (46 <UserRound data-icon="inline-start" />47 )}48 {localization.continueAsGuest}49 </Button>50 )51}
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 | |
| 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 |
