This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-react / useSession

useSession() ​

useSession(): Session

Current player session, reactive to login, logout and a renewal that changes the identity. Uses useSyncExternalStore over client.session: the reference only changes when the session changes.

On the server and during hydration it returns { status: 'anonymous' } (or the EnginexProvider's initialSession); the real session appears right after hydration.

Returns ​

Session

The Session of the nearest EnginexProvider's client.

Throws ​

If called outside an EnginexProvider.

Example ​

ts
const session = useSession()
if (session.status === 'authenticated') return <Wallet userId={session.userId} />
return <LoginButton />