Interface: AccountClientOptions
Defined in: client/accounts.ts:9
Where the accounts API is and how the session travels. Every option has a default.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
baseUrl? | string | Where the Worker is, e.g. "https://game.example.com". Defaults to the page's own origin. | client/accounts.ts:11 |
prefix? | string | Where the accounts API is served. Default "/api/accounts". | client/accounts.ts:13 |
mode? | "cookie" | "bearer" | How the session travels. "cookie" (the default in browsers): an HttpOnly cookie the page's scripts never see. "bearer" (the default elsewhere): the client keeps the session token and sends it with every request; pass session to restore one and onSession to keep it. | client/accounts.ts:20 |
session? | string | null | A session token to start with, in bearer mode. | client/accounts.ts:22 |
storage? | KeyValueStore | null | Where to keep the guest identity between visits. Defaults to localStorage when there is one. | client/accounts.ts:26 |
fetch? | (input, init?) => Promise<Response> | The fetch to use. Defaults to the global one. | client/accounts.ts:28 |
Methods
onSession()?
ts
onSession?(token): void;Defined in: client/accounts.ts:24
Called when the session token changes, in bearer mode: store it to stay signed in.
Parameters
| Parameter | Type |
|---|---|
token | string | null |
Returns
void