DocsState & inputs · FQL
On this page

Keep data live

Combine value sources and follow saved data changes.

Before you begin: Bind inputs and defaults.

Multiple Value Sources

Use a comma to declare multiple possible event sources for the same state value.

FQL state configuration

Add this configuration inside your page’s {STATE} declaration. Inspect state shows its configuration; live queries and saved data run against your local site. Try a complete FQL page →

This means $state.terms starts as true, then it can be updated by either:

  1. The hidden checkbox change event.
  2. The visible checkbox button click event.

Commas are only treated as source separators at the top level. Commas inside function calls, arrays, objects, strings, or filters stay inside that expression.

Live State

Add .live to a state key when that value should update after its saved data changes.

FQL state configuration

Add this configuration inside your page’s {STATE} declaration. Inspect state shows its configuration; live queries and saved data run against your local site. Try a complete FQL page →

The state path does not include the modifier: "messages.live" is read as $state.messages. When a live value depends on another state path, Frontbacked follows that dependency back to the saved data it needs. This lets a derived value such as productName stay live without duplicating its product query.

Frontbacked shares one live connection for the page and combines overlapping selections automatically. If several live values depend on the same post type or list, one saved-data change is turned into one fresh request for the combined selection. Theme code does not need to create sockets, subscribe to channels, or coordinate duplicate listeners.

Live values respond to saved-data changes. Browser-only values such as $query and $params still change through navigation or state updates, and $now does not become a ticking clock merely because a key is live. Every fresh live request uses the visitor's current authentication and the same FRL read permissions as the initial request.

Defaults must appear before .live:

FQL state configuration

Add this configuration inside your page’s {STATE} declaration. Inspect state shows its configuration; live queries and saved data run against your local site. Try a complete FQL page →

"productName.live('No product')", repeated or unknown modifiers, and $live inside a selector are rejected.

Read lifecycle state through $status.<statePath>:

js

Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →

The same information is available in JavaScript with Frontbacked.live.status("messages"). Use Frontbacked.live.isConnected() when you only need the page-level connection state. Frontbacked reconnects automatically, reloads only when a saved-data change was missed during the interruption, and keeps the last rendered value while reconnecting.

Continue with Derive display values.