feat(config): add shared browser cookie policy
Quality / quality (ubuntu-latest) (push) Failing after 9m46s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 21:53:07 +05:30
parent a0dab308f0
commit 5de792f359
15 changed files with 198 additions and 22 deletions
+29
View File
@@ -166,6 +166,35 @@ theme: {
The client runtime (`renderThemeRuntime`) exposes `window.wrnTheme` with `{ get, set, toggle, bind, themes }`, connects up any `[data-wrn-theme-toggle]` and `[data-wrn-theme-set]` elements on load, and persists the choice to the `wrn-theme` cookie (`max-age` 1 year, `samesite=lax`). `toggle()` cycles through the configured theme names in order.
### Shared browser cookies
Set one cookie policy for theme, accent, language, and application cookies:
```ts
export default {
cookies: {
defaults: {
domain: "example.com",
path: "/",
maxAge: 31_536_000,
sameSite: "Lax",
secure: true,
},
language: { maxAge: 2_592_000 },
},
} satisfies AppConfig;
```
The theme, accent, and language switchers use this policy automatically. Client
functions can use the same resolved policy for other values:
```ts
window.wrnCookies.set("dashboard-view", "compact");
window.wrnCookies.set("locale-preview", "hi", "language");
const value = window.wrnCookies.get("dashboard-view");
window.wrnCookies.remove("dashboard-view");
```
## Usage
### `wrnexus.config.ts`