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
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 />