Skip to main content
Canonical state contains every fact needed to run the game. A player view contains only what that viewer may see. Declare visibility on the state that owns the secret.

Hide a field from everyone

Use .hidden() for deck order, unrevealed results, and similar secrets:
Every viewer receives a hidden envelope instead of deck:

Reveal a safe summary

You can expose a derived value without exposing the secret itself:
The view contains:
The summary schema is checked when the game definition is built and when a view is produced.

Show a field to its owner

First identify the field that stores the owning player ID. Then mark private fields as visible to that player:
The owning player receives their full hand. Other players and spectators receive only its count. Use visibleToSelf() without options when non-owners should receive only { __hidden: true }.

Create views

The executor accepts a player or spectator viewer:
The returned object has game and progression. It never includes runtime RNG state or command history.
Do not copy secrets into event payloads or visible fields. Visibility rules protect state projection, not data you deliberately emit elsewhere.
The client view type automatically includes the full value or hidden-envelope union. Narrow it with "__hidden" in value before rendering private fields.

Read views in the client

Render the current viewer-safe state.