Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

useSessionList()

The useSessionList hook returns an array of Session objects that have been registered on the client device.

Usage

pages/index.tsx
import { useSessionList } from "@clerk/nextjs"; export default function Home() { const { isLoaded, sessions} = useSessionList(); if (!isLoaded) { // handle loading state return null; } return ( <div> <p>Welcome back. You have been here {sessions.length} times before. </p> </div> ) }
home.tsx
import { useSessionList } from "@clerk/clerk-react"; export default function Home() { const { isLoaded, sessions} = useSessionList(); if (!isLoaded) { // handle loading state return null; } return ( <div> <p>Welcome back. You've been here {sessions.length} times before. </p> </div> ) }
VariablesDescription
isLoadedA boolean that until Clerk loads and initializes, will be set to false. Once Clerk loads, isLoaded will be set to true
setActiveA function that sets the active session, is most cases this should be used over setSession()
setSessionA function that sets the active session, this should
sessionsHolds an array of Session objects that have been registered on the client device

Was this helpful?

Clerk © 2023