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 have been here {sessions.length} times before. </p> </div> ) }
Values | Description |
---|---|
isLoaded | A 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() . |
sessions | Holds an array of Session objects that have been registered on the client device. |