Read authentication state
After Clerk loads, inspect whether the client has an active authenticated session.
Clerk · Class
Clerk's Session object represents the current user's authenticated interaction with the server. It is accessed through Clerk and supports inspecting session state, refreshing activity, clearing cached data, and ending the session.
The Session object represents the authenticated exchange between a user and Clerk's server. Clerk creates one when the user signs in, exposes it through the Clerk object, and lets the client inspect activity, clear stale cached data, or end the session.
const session = clerk.session
await session.end()The Session object exposes session state and lifecycle methods; remove() and touch() return Promise<SessionResource>.
import { Clerk } from '@clerk/clerk-js'
const clerk = new Clerk(import.meta.env.VITE_CLERK_PUBLISHABLE_KEY)
await clerk.load()
const session = clerk.session
if (session) {
console.log(session.status)
await session.end()
}Loads Clerk, reads the currently active session, logs its status, and ends it when present.
After Clerk loads, inspect whether the client has an active authenticated session.
When session-related data has changed, invalidate locally cached session information.
When the user signs out or the application must terminate the current client session, call end().
A Session models the period of information exchange between a user and Clerk's server. Clerk creates it when the user signs in, and it is available from the Clerk object.
Follow-up: Can multiple sessions exist? Yes. A client can hold multiple sessions, but only one can be active at any given time.
Use clerk.session after loading Clerk to access the current session. The value represents the active session for the client when one exists.
Follow-up: What if no session is active? Treat the value as absent and avoid calling session methods until a session is available.
session.end() marks the session as ended for the current client and changes its status to ended. It is the client-side operation for ending that session.
Follow-up: Does this prevent every possible session termination path? No. Clerk can also expire sessions on the server for security reasons.
ClerkClientUserSessionVerificationSessionResourceclearCache()end()touch()