Storage Adapters
Where header-mode tokens live on the client.
In header mode the client needs to persist tokens somewhere across page reloads. StorageAdapter is a tiny interface — pick one of the four built-ins or write your own.
The contract
Any sync or async store works.
Built-ins
MemoryStorage (default)
In-memory Map. Tokens are lost on refresh. SSR-safe (returns null on the server). Use this for tests and prototypes.
LocalStorageAdapter
Browser localStorage. Persists across tabs and page reloads. SSR-safe.
Security trade-off: localStorage is readable by any JS in the page — if your app has an XSS hole, the tokens are leaked. Cookie mode (accessTokenType: 'cookie' with HttpOnly cookies) is the only fully-XSS-resistant option.
SessionStorageAdapter
Browser sessionStorage. Same shape as LocalStorageAdapter but cleared on tab close.
CookieStorageAdapter
Stores tokens in non-HttpOnly cookies. Useful when you want JS-readable cookies (e.g. server-component reads), but does not protect against XSS — for true HttpOnly cookies, switch to accessTokenType: 'cookie' mode and let the server set the cookies.
React Native
Pass an adapter that wraps AsyncStorage:
Custom adapter
Anything that satisfies the four-method contract. Encrypt-at-rest, server-side, secure-element… up to you. The library doesn't care.
Storage keys
The client writes these keys (prefixed with the adapter's prefix, if any):
access_tokenrefresh_tokenexpires_attrust_tokensession
If you're sharing storage with another library, prefix your adapter to avoid collisions.