Skip to content

Commit 063ee43

Browse files
janechuCopilot
andcommitted
docs(integrations): clarify entry accepts any fragment key + FAST-v3 wrapper requirement
Two small clarifications carried forward from the discussion on #299 (which was closed in favour of inline updates rather than a separate recipe page): 1. Both Node and Rust integration pages now explicitly state that `entry` / `entry_id` accepts any fragment key, not just `"index.html"`. Adds a 'webui inspect' pointer for listing the valid keys in a built protocol. 2. Calls out the FAST-v3 wrapper-file requirement: an `<f-template name="...">` block lives in the protocol's component map (not the fragment map), so it cannot be passed as `entry` directly. Adopters trying to render a single FAST-v3 component into an embedded host were hitting MissingFragment and had to read source to figure out why. Also adds a one-line distinction between `render_partial` (returns JSON for the WebUI client-side router during in-app navigation) and `render` / `WebUIHandler::handle` with `entry` (returns raw HTML for a non-WebUI host), since these two APIs were being conflated and the existing docs don't make the distinction explicit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9fc32fb commit 063ee43

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

docs/guide/integrations/node.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ Deno.serve({ port: 3000 }, (req) => {
104104

105105
`state` accepts either an object (auto-serialized) or a pre-stringified JSON string.
106106

107+
#### Selecting a fragment with `entry`
108+
109+
`entry` accepts any fragment key in the built protocol, not just `"index.html"`. Each HTML file inside `appDir` is registered under its relative path: `appDir/index.html` becomes `"index.html"`, `appDir/widgets/citation.html` becomes `"widgets/citation.html"`. List the keys in a built protocol with `npx webui inspect dist/protocol.bin`.
110+
111+
This lets a non-WebUI host pick which fragment to splice into its response. The host stays in charge of the surrounding HTML; WebUI renders the named fragment and the rest of the protocol is ignored. Passing an `entry` that does not match a key throws an error.
112+
113+
FAST-v3 components are an exception: an `<f-template name="my-component">` block is stored in the protocol's component map, not the fragment map, so it cannot be passed as `entry` directly. To render a single component for embedding, add a thin wrapper HTML file (e.g., `<my-component></my-component>` saved as `src/my-component-entry.html`) and pass that wrapper's key as `entry`.
114+
115+
> `renderPartial` (see [Routing](/guide/concepts/routing)) is a different API: it returns a JSON object consumed by the WebUI client-side router during in-app navigation. Use `render` / `renderStream` with `entry` when you want raw HTML for a non-WebUI host.
116+
107117
### BuildOptions
108118

109119
| Field | Type | Default | Description |

docs/guide/integrations/rust.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ HttpResponse::Ok()
247247
| `with_head_inject(&str)` | builder | Raw HTML emitted immediately before `</head>` at the parser's structural boundary (see [Streaming SSR](#streaming-ssr)). |
248248
| `with_body_inject(&str)` | builder | Raw HTML emitted immediately before `</body>`. Same structural-boundary contract. |
249249

250+
#### Selecting a fragment with `entry_id`
251+
252+
`entry_id` accepts any fragment key in the built protocol, not just `"index.html"`. Each HTML file inside `appDir` is registered under its relative path: `appDir/index.html` becomes `"index.html"`, `appDir/widgets/citation.html` becomes `"widgets/citation.html"`. List the keys in a built protocol with `webui inspect dist/protocol.bin`.
253+
254+
This lets a non-WebUI host pick which fragment to splice into its response. Implement `ResponseWriter` (see the Examples above) to push chunks onto whatever the host expects (a `Vec<u8>`, an `axum::body::Bytes` channel, a websocket frame), and call `handler.handle(&protocol, &state, &options, &mut writer)` with the matching `RenderOptions::new(entry_id, request_path)`. Passing an `entry_id` that does not match a key returns `HandlerError::MissingFragment(name)`.
255+
256+
FAST-v3 components are an exception: an `<f-template name="my-component">` block is stored in the protocol's component map, not the fragment map, so it cannot be passed as `entry_id` directly. To render a single component for embedding, add a thin wrapper HTML file (e.g., `<my-component></my-component>` saved as `src/my-component-entry.html`) and pass that wrapper's key as `entry_id`.
257+
258+
> `render_partial` (see [Routing](/guide/concepts/routing)) is a different API: it returns a JSON object consumed by the WebUI client-side router during in-app navigation. Use `WebUIHandler::handle` with `entry_id` when you want raw HTML for a non-WebUI host.
259+
250260
### HandlerError variants
251261

252262
| Variant | When |

0 commit comments

Comments
 (0)