Alt description missing in image
Beta: Plugins coming soon!

useSession()

import { useSession } from '@auth/clerk'
        • useSession()

Access the active session and session-related helpers with a universal import path.

Usage

SessionInfo.tsx
import { useSession } from '@auth/clerk'
 
export const SessionInfo = () => {
    const { isLoaded, session, sessionId } = useSession()
    if (!isLoaded || !session) return null
    return <Text>Session: {sessionId}</Text>
}

API

Returned values

  • isLoaded: boolean — Whether the session data is hydrated.
  • session?: SessionResource — The active session object, if any.
  • sessionId?: string — The active session id, if any.
See official docs for the full session shape: https://clerk.com/docs/nextjs/reference/hooks/use-session