Session-aware status UI
Display how many sessions are registered for the current user.
Clerk · Hook
useSessionList() exposes the current user's sessions registered on the client device. Use isLoaded to wait for Clerk initialization before reading sessions or using session-management operations.
Call the hook without arguments and destructure its result. While Clerk initializes, use isLoaded to show a loading state; afterward, sessions contains the current user's registered client-device sessions, and the returned session-management methods can be used when needed.
useSessionList()An object containing isLoaded, sessions, and session-management methods; after loading, sessions is SessionResource[].
import { useSessionList } from '@clerk/react'
export default function Home() {
const { isLoaded, sessions } = useSessionList()
if (!isLoaded) return <div>Loading...</div>
return <p>Previous visits: {sessions.length}</p>
}Wait for Clerk to finish loading, then render the number of registered client-device sessions.
Display how many sessions are registered for the current user.
Offer controls that change the active session or organization.
Show a loading state while Clerk initializes authentication data.
useSessionList() takes no arguments and returns session-list state and management helpers. The central fields are isLoaded, which indicates whether Clerk has loaded authentication state, and sessions, which contains registered SessionResource objects.
Follow-up: What should the UI do before initialization completes? Render a loading state and avoid reading sessions until isLoaded is true.
The hook exposes sessions as a SessionResource[] after loading. Before Clerk finishes loading, the corresponding state may be undefined, so components should gate access with isLoaded.
Follow-up: Why is a length check alone insufficient? Because sessions may not yet be available during the loading phase.
Use the hook when a React component needs to inspect or manage the current user's sessions registered on the client device. It is useful for session-aware UI such as showing prior visits or offering session-management controls.
Follow-up: How can the UI remain correct during organization switching? Reapply the loading guard because authentication state can temporarily become unavailable.
useSessionsetActiveSessionResource