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
3df8ffff548ffa485acc1b83a4015ff840da7a431ad2643c495624128fb8f2f7a10231c0304ab234727eba63520e17ddbd33c2282ce2e79af742e63a4a7377b5

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...