Developer guide
Muse and Hatch widgets: a React developer's guide
Understand the evidence behind Muse's Hatch widget bridge and design React components that survive changes to their host.
Draft preview — this article has not been published.
By ELFUpdated Evidence reviewed
You can organize a React library for Muse without putting Muse APIs inside every component. Keep the component's inputs and interactions explicit, then let a small adapter connect that component to the host. This is our recommended architecture because the public evidence for the exact Hatch widget bridge is narrower than the evidence for Muse as a product.
Evidence reviewed November 7, 2026. The exact bridge described below comes from a dated community observation. We have not independently certified it against a live Muse client. Treat its integration as experimental until your own host checks pass.
What “Hatch” tells us—and what it does not
Meta's engineering account describes Muse's isolated runtime and distinguishes it from durable application state held outside that runtime. That architecture explains why a file in an agent's working directory and a saved item in a product need separate lifetime rules. It does not establish a public React widget SDK or expose the platform's database as a widget API. Meta's Muse architecture account is the official source for that broader context.
For the exact widget interface, the available public source is Jules Kuehn's Muse architecture tour, compiled from a September 24, 2026 session. It reports an HTML fragment surface and the following bridge:
| Reported interface | Reported role |
|---|---|
window.hatchWidget.getState(defaults) | Read the current snapshot, using initial defaults when needed. |
window.hatchWidget.setState(nextState) | Replace the complete snapshot after an interaction. |
hatch-widget-state | Receive an updated snapshot through event.detail.state. |
The same capture reports a 1 MB HTML limit and host-provided theme variables. These are community-observed details, not a maintained public compatibility promise from Meta. The name hatchState should not be treated as interchangeable with window.hatchWidget; verify the actual object exposed in your target environment.
Keep the experimental bridge in one place
For a reusable library, use three layers:
| Layer | Responsibility | Example |
|---|---|---|
| Component | Render values and express user intent. | A checklist receives rows and emits onToggle(id). |
| Controller | Validate data, apply domain rules, track pending work. | A checklist controller handles commands and exposes a cached snapshot. |
| Host adapter | Translate transport and lifecycle behavior. | A Hatch adapter reads a host snapshot and listens for host updates. |
The component should not search window for a bridge, write browser storage, or choose an identity. Those decisions belong to the controller and adapter. This makes the same view useful in a local demo, a Muse experiment, an MCP App, and a hosted application.
Select the adapter at the application entry point. If a required bridge is missing, show a clear unavailable state or an explicitly labeled local demo. Silently switching a production editor to memory storage would make a successful click look like a successful save.
A snapshot API leaves important questions open
Our interpretation of the reported full-snapshot interface is deliberately limited. Replacing an object does not demonstrate atomic compare-and-swap, transaction isolation, shared editing, or conflict resolution.
Imagine two clients starting with the same checklist. One checks an item while the other adds a row. If both send whole snapshots, the last accepted write could discard the other change unless the host supplies additional coordination. An adapter cannot manufacture a safe distributed merge from a setter alone.
Choose an explicit application policy:
- For a personal prototype, document a single active editor and test how host updates interact with local edits.
- For shared records, use an authoritative backend with revisions and typed commands, if the host supports an authorized route to it.
- When the host offers neither reliable coordination nor backend access, avoid promising shared editing.
These are application design choices. They are not claims about undocumented Muse behavior.
Version data separately from the widget's code
Use a small state envelope that your code owns:
type ChecklistEnvelope = {
schemaVersion: 1;
documentId: string;
data: {
rows: Array<{ id: string; label: string; checked: boolean }>;
};
};
Validate every incoming snapshot before rendering it. Apply migrations only for versions your code understands. If a newer schema appears, preserve the raw data and enter a read-only or upgrade-required state; do not replace it with defaults. Distinguish “no saved record” from “saved record is empty.” An empty checklist can be a user's intended result.
Initialization belongs in the adapter lifecycle. Rendering should read an already available snapshot. It should not seed defaults, register duplicate listeners, or persist changes as a side effect of asking React for the current value. See portable React state for the synchronous store contract.
npm authoring and widget delivery are different stages
You can develop a component with normal package imports and compile it into a browser artifact. Browsers resolve modules using URLs and, where configured, import maps; they do not use a widget's imaginary node_modules directory. MDN's module guide describes that distinction.
Our recommended portable profile bundles dependencies before delivery. That recommendation does not prove Muse bans every external script, and it does not require copying package source files byte for byte. Preserve one maintained source tree, then record the exact versions and hashes used to produce each artifact. The bundle guide explains the build boundary.
What to verify before calling an adapter compatible
Record a host, client version or test date, artifact hash, and fixture for each result. At minimum, check initial creation, user edits, reopening, host-originated updates, empty state, invalid state, older schemas, missing bridge, and theme changes. For any durability claim, include a real reopen or second-client test appropriate to that claim.
Successful rendering proves the view can render. A mock bridge proves the adapter follows the mock's contract. Neither alone establishes durable cloud synchronization. Keep those claims separate in package documentation and in the interface's save status.
For the product-level distinction between a widget and a reusable Muse experience, continue with Muse Spaces, sites, and persistence.