Globetrotter docsversion 0.3.0 · 2026-12-04

Connect data

On this page
  1. The loop
  2. Who owns which file
  3. Four words
  4. Rows
  5. Every moment of a list
  6. Forms
  7. Every word, in your language
  8. What the generator writes
  9. Where services, state and stores go
  10. What catches each kind of drift
  11. Not in the design, on purpose
  12. Try next

How design and code stay in sync, and where your own code goes. Everything here is enforced by tools, not by discipline.

The loop

The sync loop
The sync loop

One file per app is the truth: designs/<name>.design.json. The studio, Claude Code through the MCP tools, and anyone editing JSON followed by npx globetrotter sync all write it, through the same validation and the same generator. Writers carry the hash of what they last read, so two editors cannot overwrite each other: the loser gets a 409 and the studio offers Reload or Keep mine.

The first time, step by step, on a real page: Build a page (a list bound to offers, the binding sync wrote, a handler).

Who owns which file

File ownership
File ownership

A generated page never contains anything that is not in the design: no data, no handlers, no state beyond what widgets need to behave. Everything else enters through one import, the page's binding module, which is yours.

Four words

The page's data contract in the page panel
The page's data contract in the page panel

In the design panel, the link button beside a prop binds it to a path; the value you had stays as the sample the canvas shows. Repeat over makes a node a template for a collection. Action names a handler. Field makes an input two-way. An action nothing answers says so, and its Calls picker lists the service's commands:

The Calls picker on a form's Submit action, set to Tasks.add: the contract line reads "calls Tasks.add (POST /tasks/actions/add)"
The Calls picker on a form's Submit action, set to Tasks.add: the contract line reads "calls Tasks.add (POST /tasks/actions/add)"

In the design file:

{ "type": "StatTile", "props": { "label": "Unread", "value": { "$bind": "stats.unread", "sample": "12" } } }
{ "type": "ListItem", "props": { "repeat": "conversations", "text": { "$bind": "item.title", "sample": "Design review notes" }, "action": "open" } }
{ "type": "Fab", "props": { "icon": { "$icon": "Edit" }, "label": "Compose", "action": "compose" } }
{ "type": "TextField", "props": { "label": "Title", "field": "draft.title" } }

A row can hold one value of its own: a Checkbox, Switch or toggle IconButton (toggle: true) bound to a boolean of the row (field: "item.done" on a Checkbox or Switch; selected: {"$bind": "item.done"} on the IconButton) with an action. The page draws it from the row (checked={item.done}), and a press calls actions.<action>(item): the binding stub flips that row at once and sends the update with only the id and that value (toggle-selected-dropped no longer applies there; row-toggle-needs-action and row-toggle-unanswered say what is missing). Any other input in a repeat is still an error.

A repeat inside a repeat nests ("repeat": "item.replies"). An action on a repeated node receives that item. Describe each action once (What it does section, the What does box under the action's name) and the sentence becomes the JSDoc on its type, the TODO in the stub and the OpenAPI summary.

Rows

Drawn rows become a list in one step. Set Repeat over on one of several rows alike and the others fold in as its samples; what differed between them is bound to a field of each row.

Repeat over typed on the second of three rows alike: before Enter, the field says the other two fold in as its samples
Repeat over typed on the second of three rows alike: before Enter, the field says the other two fold in as its samples

Give the rows their own samples ("samples": [...] on a bound prop), or Vary the rows fills them in: times step back, amounts keep their currency, names come from one cast. Paste real rows from a spreadsheet or an API's JSON onto a selected row and each field takes the column of its name.

A Data table repeats the same way ("repeat": "schedule", fields naming the item field each column shows); the binding returns plain objects.

A binding is a stub until you edit it. Sync writes src/bindings/<slug>.ts and keeps it in step with the design (new fields, new sample rows, a handler stub name: () => { /* TODO */ } for each action) until your first edit; from then on it is yours and sync never touches it. An action you name after that is not added for you: the Inspector's On press says "The binding has no handler “name” yet." with the line to copy into actions (Build a page).

Every moment of a list

An empty state selected: the list shows empty, as the page will when the data has nothing in it
An empty state selected: the list shows empty, as the page will when the data has nothing in it

A node with "whenEmpty": "conversations" is that list's empty state, shown only once the data has loaded with nothing in it. "whenLoading": true on loading rows shows them while the binding says status: 'loading'; they take the shape of the list's own rows every time the page is generated. "whenError": "jobs" is the error state, whose Try again names the reload action. "whenError": true is the page's own failed state, for a page with no list to name (it shows while the binding says status: 'error', as "whenLoading": true shows while it loads); the studio's Failed state draws it. The page panel's Lists section (under More) keeps the three in view.

A page for one record has a route with a parameter: /tasks/[id] ([name] is a whole segment; the app serves /g/tasks/7, after the exact routes). It is never a navigation destination. A link carries the key: "href": "/tasks/[id]" on a row inside a repeat is item.id, on a page whose own route has [id] it is that page's (params.id); anywhere else lint's link-needs-key is an error. Its binding reads the record with the service's get (a Query with id in the path), shows status: 'loading', and says 'missing' when none has that id: "whenMissing": true on a node is the not-found state, "whenMissing": false is what shows while the record is there. The contract's path is /tasks/{id}.

The fieldops Jobs list on a phone: waiting as rows shaped like its own, failed with Try again and the snackbar, and loaded
The fieldops Jobs list on a phone: waiting as rows shaped like its own, failed with Try again and the snackbar, and loaded

What just happened. The binding returns notice ("Removed Fjord parka") and the page shows it for a moment, with Undo when undo is set. Anything named for taking something away wants both. npx globetrotter presses presses every action in the app on a phone and fails one that changes nothing in view and says nothing.

Controls that follow the data. A yes/no prop can be a condition: "disabled": { "$bind": "lines", "when": "empty" } keeps Checkout off while the cart is empty; { "$bind": "status", "when": "loading" } keeps a Create button off while its request runs, so it is never pressed twice.

Forms

A rejected New job: the Title field the API named, in its error state with the focus and the message under it
A rejected New job: the Title field the API named, in its error state with the focus and the message under it

A field with "field": "draft.title" reads data.draft.title and calls actions.change("draft.title", value) as the user types; the types declare a <Page>Fields map so change is typed per path. Enter in the last field sends the form; on a phone the keyboard shows Next until then. The binding returns fieldErrors by path and each field shows its own, in its error state, the first taking the focus. The Form template comes wired this way, and from an entity its inputs fit each field's type. After a create that leads to the list, the stub leaves "Task added." there. A field the called command has no param for is one contract-drift finding naming the input and the required param nothing sends.

What a form sends. An input holds text as it is typed, so the page types say string (a switch or checkbox, boolean). The binding stub sync writes sends what the contract's request schema says of each param, and says so in the types (a line over the field: "Text as typed; sent as priority, a number."): an integer or number param is sent as a number (asNumber), a date as the ISO day (asDate), a date-time as a moment with its zone (asDateTime), and a blank is left out so the service says what is missing. A decimal stays text on the wire (the contract says string, format: decimal), and a switch goes as a boolean. Set the TextField's type to number or date so the phone shows the right keyboard; the service still refuses "3" for a whole number, it is never loosened. Rows coming back are presented for reading by the stub (present): a decimal without its trailing zeros (2.5000 shown 2.5) and true/false in the design's yes/no words (Words panel). A binding you have edited keeps its own code: where it sends one of these raw (priority: data.draft.priority), handoff and design_status name the line (wrap it: Number(data.draft.priority)).

Every answer the backend can give. Beside a generated backend, a refusal always has one shape, { error, field?, fields? }, and the binding stub sync writes reads it in one place: the fields it names (fields, every one at once, in the design's own words) go under their inputs as fieldErrors, anything else (error: a 401 or 403 in words, a 404, a 409, a body over 2 MB, a 500 that says it is logged) goes to the snackbar as status: 'error'. A service that cannot be reached at all (the phone offline, the backend down) is said the same way ("The service could not be reached…") and the form keeps what was typed; the request is never left loading. A slow answer is loading until it comes: the app bar shows progress and a button whose disabled follows the status cannot be pressed twice. A screen reader hears all of it: the snackbar's words are read a moment after they show (a region that is on the page from the start is given them; one mounted with its words is read by few readers), a first load that took a while ends with "Shop loaded.", a refused field is read as the focus lands on it — again when it was already there — and a row's button says which row it is for ("Remove, Fjord parka"); repeated grid items are a list, so "list, 6 items".

Every word, in your language

npx globetrotter words (or get_words) is one sheet of every word the person reads: the widgets' words page by page, then the pages' own under Every page (the notice's Undo, "Refreshing jobs", what the binding says offline) and, beside a backend, the service's refusals under Backend ("A job needs a title.", "No job has that id.", the 413). Translate the Words column, --apply it (or set_words; the studio's Words panel edits the same rows in place): the pages are regenerated, the service's words.py and words.rs at the next sync. {page}, {field}, {n} and the like are kept where they stand — a line that drops one is refused. In words you write, {entity} and {field} are the bare names ("job", "title"): the article is yours, as it is in any language. Two things stay the developer's: what a binding you have edited says (its own notices), and a choice's words, which the page also sends — translate "Low, Normal, Urgent" and the service's choices go with it, or the send is refused and contract-drift says so.

What the generator writes

From a bound prop to a running page
From a bound prop to a running page

Every save of a page with bindings writes:

  • src/generated/<slug>.types.ts: InboxData, one Inbox<Collection>Item per repeated node, InboxActions, InboxFields, and InboxBinding with status, error, notice, fieldErrors. Beside a backend, a row whose action sends its key to the service carries id in its type, so tsc marks a binding whose rows leave it out, as it marks an action the binding never gives; design_handoff and globetrotter status say both.
  • src/generated/<design>.openapi.json: the same contract as OpenAPI 3.1. GET /inbox returns the data; POST /inbox/actions/compose performs the action; an item action posts the item. Give it to the backend, mock it, generate a client.
  • the page: const { data, actions, status, error } = useInboxPage(), a progress bar while loading, the error and the notice in a snackbar, every link through useNavigate() with its transition.
Code & handoff: the generated page
Code & handoff: the generated page
Code & handoff: the OpenAPI view
Code & handoff: the OpenAPI view

And once, src/bindings/<slug>.ts: a stub that returns the samples so the page runs on day one, and follows the design until you edit it. From then on it is yours. A list that fails to load shows no rows, not the samples. Beside a backend it already calls the service, and after an action goes where a person expects: the page whose data the command answers, the first page after sign-in, or a notice that it was done.

Where services, state and stores go

In the binding module, or in what it imports. Three shapes that satisfy the same types:

A local store (mail, Zustand):

export function useInboxPage(): InboxBinding {
  const { unread, conversations, compose } = useInboxStore();
  return { data: { greeting: `You have ${unread} unread`, stats: { unread: String(unread), unreadDelta: '+4' }, conversations }, actions: { compose } };
}

A service through React Query, against the OpenAPI operations:

export function useInboxPage(): InboxBinding {
  const qc = useQueryClient();
  const q = useQuery({ queryKey: ['inbox'], queryFn: () => fetch('/api/inbox').then((r) => r.json() as Promise<InboxData>) });
  const compose = useMutation({ mutationFn: () => fetch('/api/inbox/actions/compose', { method: 'POST' }), onSuccess: () => qc.invalidateQueries({ queryKey: ['inbox'] }) });
  return { data: q.data ?? SAMPLE, actions: { compose: () => compose.mutate() }, status: q.isPending ? 'loading' : q.isError ? 'error' : 'ready', error: q.error?.message };
}

Route handlers (fieldops, storefront): implement the OpenAPI operations under src/app/api/... and fetch them. The types and the API come from one tree, so they cannot disagree.

The mail example's bound Inbox page after Compose
The mail example's bound Inbox page after Compose
The same page at phone width, from the same design and the same binding
The same page at phone width, from the same design and the same binding

What catches each kind of drift

Drift Caught by
Design changed, code not regenerated npx globetrotter sync --check (CI)
Someone edited a generated file its @generated-hash; the next sync keeps their version in .hand-edited/ and writes the fresh one
The design binds a new path or drops one tsc fails in the binding
Two editors save at once the hash check: 409, Reload or Keep mine
A malformed path, item.* outside a repeat, an empty state for nothing lint rule contract, on the node
A component where nothing allows it (a widget in a place that takes only others) the save is refused, studio and MCP alike
The widget package changes its props npx globetrotter check
A press that changes nothing, a page that throws, a problem a screen reader meets presses, monkey, a11y, states, journeys in the app
A page and its service disagree (a form field the entity lacks, a list row or a form field named for what a renamed field was called, an action calling a path nobody serves) lint rule contract-drift, on both sides, an error with the field it probably means and a Fix (apply_fix(design, page, "contract-drift")), so sync --check fails; the side that does not own the path is asked to move (Studio and agents)

In your project: npx globetrotter sync --check && npx tsc --noEmit.

Not in the design, on purpose

Business logic, fetching, auth and caching (the binding); component internals (the widget library); routing beyond href (your app router); styling outside tokens. If you want one of these in a design, the right move is a new widget in the library so every project gets it, or a binding.

Try next

  1. In the mail example, unbind the Unread tile's value and run npx tsc --noEmit -p examples/mail: the binding now has an extra field.
  2. Bind the Archived tile instead and watch the types, the OpenAPI and the stub change in Code & handoff.
  3. Set Repeat over on a Card in a grid and bind its headline to item.title.