useSessionList()
The useSessionList() hook returns an array of Session
Returns
There are multiple variants of this type available which you can select by clicking on one of the tabs.
- Name
isLoaded- Type
false- Description
A boolean that indicates whether Clerk has completed initialization. Initially
false, becomestrueonce Clerk loads.
- Name
sessions- Type
undefined- Description
A list of sessions that have been registered on the client device.
- Name
setActive- Type
undefined- Description
A function that sets the active session and/or Organization. See the reference doc
.JavaScript Icon
- Name
isLoaded- Type
true- Description
A boolean that indicates whether Clerk has completed initialization. Initially
false, becomestrueonce Clerk loads.
- Name
sessions- Type
SessionResource []JavaScript Icon - Description
A list of sessions that have been registered on the client device.
- Name
setActive()- Type
(setActiveParams: SetActiveParams ) => Promise<void>JavaScript Icon - Description
A function that sets the active session and/or Organization. See the reference doc
.JavaScript Icon
Example
Get a list of sessions
The following example uses useSessionList() to get a list of sessions that have been registered on the client device. The sessions property is used to show the number of times the user has visited the page.
import { useSessionList } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
export default function Home() {
const { isLoaded, sessions } = useSessionList()
// Handle loading state
if (!isLoaded) return <div>Loading...</div>
return (
<div>
<p>Welcome back. You've been here {sessions.length} times before.</p>
</div>
)
}Feedback
Last updated on