Documentation · Chapter 10

Manage navigation and persisted state.

Engine updates RouterView, history, metadata, focus, shared context, and optionally local or session persistence.

Every lesson starts from the problem, explains the mechanism, then gives a concrete verification.

Navigation is more than innerHTML

Route navigation updates history, document metadata, focus, scroll behavior, and Loading/Error/NotFound states, not just visible markup.

phpaml — zsh
#[State, Shared('cart.count'), Persisted('local', 'shop.cart', version: 2, expiresAfter: 86400)]
private int $count = 0;

Persist deliberately

#[Persisted('local')] survives a browser restart; session persistence survives only the tab session. Version and expiry prevent stale formats from living forever.

Shared state needs a name

#[Shared('cart.count')] gives several components the same named state. Unnamed local state stays owned by its page or component.