Hook that creates and manages a signed session token for a Handle.
When handle is provided, creates a Session with the given options.
Supports auto-renewal: when autoRenew is true (default), a timer
fires at half the session TTL to create a fresh session with a new
jti (the previous token remains valid until its own expiry, but the
lineage identity is preserved through handle). Background tabs
throttle (clamped wakeups) or fully suspend timers, so on return to
visibility the hook additionally renews proactively when the session
is already past its half-life point (BL-51) — the overdue timer path
alone could leave the first user actions racing an expired session.
On unmount, all timers are cleaned up to prevent state updates after
the component is gone.
Dependencies: [handle, renew] — the options object is read through
a ref, so passing a fresh object literal on every render does NOT
re-trigger session creation. Only changes to handle (or to the
renewal function identity, which follows handle) do.
Hook that creates and manages a signed session token for a Handle.
When
handleis provided, creates a Session with the given options. Supports auto-renewal: whenautoRenewis true (default), a timer fires at half the session TTL to create a fresh session with a new jti (the previous token remains valid until its own expiry, but the lineage identity is preserved throughhandle). Background tabs throttle (clamped wakeups) or fully suspend timers, so on return to visibility the hook additionally renews proactively when the session is already past its half-life point (BL-51) — the overdue timer path alone could leave the first user actions racing an expired session.On unmount, all timers are cleaned up to prevent state updates after the component is gone.
Dependencies:
[handle, renew]— the options object is read through a ref, so passing a fresh object literal on every render does NOT re-trigger session creation. Only changes tohandle(or to the renewal function identity, which followshandle) do.