what

Application Data

Global state shared across all users. Application data persists in the database and is visible to every visitor.

What Is Application Data

Session variables are per-user. Application data is shared by everyone — when one user increments a counter, every other user sees the new value on their next page load.

Common use cases:

  • Site-wide counters (total visits, total likes)
  • Feature flags (maintenance mode, beta features)
  • Global settings (site name, announcement text)

Declaring Application Variables

Declare application variables in the <what> block of your application.what file. This is typically at the project root or a directory-level config.

application.what
data.application = ["total_visits", "likes", "featured_post"]

This registers the keys so the framework knows to load them from the database and make them available in templates.

Displaying Values

Use the #app.key# syntax to display application data in any template:

<p>This site has been visited #app.total_visits# times.</p>
<p>Total likes: #app.likes#</p>

Application variables are reactive — like session variables, they are wrapped in <span w-bind="app.key"> so they update via out-of-band swaps when mutated.

Mutating Values

Use w-set with the app. prefix to mutate application data:

<button w-set="app.likes += 1">Like This Site</button>

<button w-set="app.featured_post = 'getting-started'">
  Feature This Post
</button>

Mutations are atomic — the framework uses a read-modify-write cycle in the database to prevent race conditions when multiple users mutate the same key simultaneously.

Combining with Session

A single w-set expression can update both session and app data using semicolons:

<button w-set="app.total_votes += 1; session.my_votes += 1">
  Vote
</button>

This increments the global vote count and tracks the user's own vote count in their session — all in one request.

Security

Important: Only authenticated users can mutate app.* variables via w-set. Unauthenticated requests to modify application data are rejected. Reading (#app.key#) is available to everyone.

If you need public counters (like a page visit counter that increments for anonymous users), use session variables for the per-user tracking and a server-side mechanism to aggregate totals.