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 have been here {sessions.length} times before. </p> </div> ) }
ValuesDescription
isLoadedA boolean that is set to false until Clerk loads and initializes.
setActive()A function that sets the active session.
setSession() (deprecated)Deprecated in favor of setActive().
sessionsHolds an array of Session objects that have been registered on the client device.

What did you think of this content?

Clerk © 2024