what

State Management

Server-side state management with application-wide and per-session counters, plus reactive session variables.

Application Counter

This counter is shared across all browsers and all sessions — every visitor, in any browser, sees and increments the exact same value (unlike the per-browser session counter below). Use w-set to mutate application state declaratively from HTML.

8
<button w-set="app.app_counter += 1">+1</button>

Application data persists across all sessions and is stored server-side. Atomic read-modify-write prevents race conditions under concurrent access.

Wired Counter (Real-time)

This counter updates in real time across all connected browsers via WebSocket. Open this page in two tabs or two browsers and watch them stay in sync.

4
<button w-set="wired.wired_counter += 1">+1</button>
<span>4</span>

Wired state is like application state, but pushes updates to every connected client instantly. No WebSocket code needed — just use wired.* in your w-set attribute.

Session Counter

This counter is private to this browser. Open the page in a different browser (or a private/incognito window) and you'll get a separate count — it's tied to your session cookie, not shared. Contrast with the application counter above, which is the same for everyone.

0
<button w-set="session.counter += 1">+1</button>

Session data is tied to your browser session and resets when the session expires.

Session Variables

Template variables like provide direct access to session state. These are automatically wrapped with reactive bindings for live updates.

Session Counter Value
Session ID
63d1ccf3da39d059a7dffb60b0628f2c4a74e72c8210ed99c55c236639592eb8a83221fc312bfa937a21abdb1ddf2c665c77e37e424b33dcd74790947f757a61

Session variables update reactively when their values change on the server.

Clear Session Data

Reset all session-specific data, including counters and any stored session variables.

Source

Loading...