Active Sessions
better-auth-ui/active-sessionsFreeComponent
Display and manage all active sessions for the current user with revoke controls. Shows each session's browser, OS, and creation time.
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/active-sessions.jsonSource
1"use client"23import { useAuth, useListSessions, useSession } from "@better-auth-ui/react"4import { Fragment } from "react"5import { Card, CardContent } from "@/components/ui/card"6import {7 Item,8 ItemContent,9 ItemGroup,10 ItemMedia,11 ItemSeparator12} from "@/components/ui/item"13import { Skeleton } from "@/components/ui/skeleton"14import { cn } from "@/lib/utils"15import { ActiveSession } from "./active-session"1617export type ActiveSessionsProps = {18 className?: string19}2021/**22 * Render a card listing all active sessions for the current user with revoke controls.23 *24 * Shows each session's browser, OS, IP address, and creation time. The current session is marked25 * and navigates to sign-out on click, while other sessions can be revoked individually.26 *27 * @returns A JSX element containing the sessions card28 */29export function ActiveSessions({ className }: ActiveSessionsProps) {30 const { authClient, localization } = useAuth()31 const { data: session } = useSession(authClient)3233 const { data: sessions, isPending } = useListSessions(authClient)3435 const activeSessions = [...(sessions ?? [])].sort((activeSession) =>36 activeSession.id === session?.session.id ? -1 : 137 )3839 return (40 <div>41 <h2 className="text-sm font-semibold mb-3">42 {localization.settings.activeSessions}43 </h2>4445 <Card className={cn("p-0", className)}>46 <CardContent className="p-0">47 {isPending ? (48 <SessionRowSkeleton />49 ) : (50 <ItemGroup className="gap-0">51 {activeSessions?.map((activeSession, index) => (52 <Fragment key={activeSession.id}>53 {index > 0 && <ItemSeparator />}54 <ActiveSession activeSession={activeSession} />55 </Fragment>56 ))}57 </ItemGroup>58 )}59 </CardContent>60 </Card>61 </div>62 )63}6465function SessionRowSkeleton() {66 return (67 <Item>68 <ItemMedia>69 <Skeleton className="size-10 rounded-md" />70 </ItemMedia>71 <ItemContent>72 <Skeleton className="h-4 w-20" />73 <Skeleton className="h-3 w-32" />74 </ItemContent>75 </Item>76 )77}
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 | |
| 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 | |
| Auth Redirectauth-redirect | better-auth-ui | Components | Free | 3 deps |
