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

Reference / @getenginex/sdk / SessionApi

SessionApi ​

Read access to the current session.

Methods ​

get() ​

get(): Session

Current session: a frozen object, with the same reference between calls while the tokens do not change. Safe to use with useSyncExternalStore (React) without a re-render loop.

Returns ​

Session

Example ​

ts
if (enginex.session.get().status === 'authenticated') showWallet()

subscribe() ​

subscribe(listener): () => void

Subscribes to session changes; returns the function to cancel.

Parameters ​

listener ​

(session) => void

Returns ​

() => void

Example ​

ts
const off = enginex.session.subscribe((s) => console.log(s.status))