This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.
Platform facts and localization
Host-owned facts arrive through five reserved sources: exactViewport,
exactPage, exactDelivery, exactSurface, and exactTime (the date, locale and
time zone). Declare the fields you read with their supported names and types;
the bake refuses a field the source does not have, though compilation alone does
not.
contract
shape Viewport
width: number
height: number
component Responsive
resource viewport = exactViewport() as shape Viewport
view
column
if viewport.width >= 900
text "Wide layout"
else
text "Compact layout"
exactPage().platform identifies the host from the first frame. Declare
platform: string or an enum over the following values in the page resource's shape.
The native hosts report
ios, macos, tvos, watchos, android, linux or windows.
A browser or server-rendered web page reports web, a terminal app reports
terminal, and a runner booted without a host reports headless. A browser
on an Android phone therefore reports web.
exactPage answers the page's facts by the web's names: visibilityState
("visible" or "hidden"), onLine, canShare, canOpenFiles, and
hasFocus, which is document.hasFocus(): true while the app's window has the
system's focus, false while another app or window is in front. An app that
tells the person something can show it in the window while it has focus and
post a notification otherwise.
contract
shape Page
hasFocus: bool
component Finished
resource page = exactPage() as shape Page
view
main
if page.hasFocus
text "Build finished" role="status"
Prefer responsive branches driven by dimensions and actual capabilities to
inventing platform-specific Contract files. Safe-area lengths use CSS env();
viewport metadata uses the root element's viewport-fit and interactive-widget
attributes. exactViewport also carries prefersReducedMotion,
prefersReducedTransparency, prefersContrast and prefersColorScheme: facts
for the app to honor, not automatic engine policy. displayMode: string reads
CSS's current display-mode: the browser's media query on the web (in Chrome,
an agent's prefer display-mode replaces the reading and leaves the query
alone), fullscreen or standalone for the window on macOS, and standalone
on other native hosts. On exactPage, navigationType is how the browser loaded the page
(navigate, reload or back_forward), and empty in a native app. Available fields are documented beside their source validation (LLP 1039); start with the viewport corpus.
Localized strings live in the app's strings/<locale>.json files. Author calls
such as t("greeting", name=person.name), with {name} in the table value. The
key must be a literal; keys and placeholder names are checked at compilation. The
base table is en unless app.json sets strings.base, and a translation may
omit keys but not add them. The locale comes from the host; lookup falls back from
the exact tag to shorter tags, then to the base. An app's own language setting
calls setLocale("de") in its action, and setLocale("") for "System": the
choice stands over the host's locale, is kept across launches, and applies before
the next launch's first frame, so the setting needs no mount task.
exactTime().resolvedLocale follows it; locale and formatLocale stay the
device's. See
the locale fixture and
the string tests.
formatTime, formatDate, formatDay and formatNumber are deterministic
formatting calls with specific accepted format literals. They format in the
locale of the strings table the app shows, as Intl formats it: with a de table
formatDate(at, offset, "medium") is 26.09.2026 and formatNumber(1234.5, "decimal") is 1.234,5, and setLocale moves them with the text. An app with no
tables, or only English ones, prints en-US. A table's region is its formats' region,
so an app that wants British dates ships strings/en-GB.json (it may be {}).
The viewer's forced 12- or 24-hour clock applies; dates are Gregorian in every
locale (formatting by locale). Their
vocabulary is not a general Intl options object. App-specific wording belongs in
app fns.
Is this helpful
Last updated November 30, 2026