useSessionList()
The useSessionList
hook returns an array of Session
objects that have been registered on the client device.
Usage
pages/index.tsximport { 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.tsximport { 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> ) }
Variables | Description |
---|---|
isLoaded | A boolean that until Clerk loads and initializes, will be set to false. Once Clerk loads, isLoaded will be set to true |
setActive | A function that sets the active session, is most cases this should be used over setSession() |
setSession | A function that sets the active session, this should |
sessions | Holds an array of Session objects that have been registered on the client device |