microsoft-webui-cli
Command-line tool for the WebUI framework — build, serve, and inspect WebUI applications.
Install
This installs the webui binary.
Commands
webui build
Build a WebUI application into a compiled protocol and CSS files.
| Option | Default | Description |
|---|---|---|
APP |
. |
Template/component directory |
--out |
(required) | Output directory for protocol.bin + CSS, or a .bin file path to customize the protocol filename (e.g. ./dist/app1.bin) |
--entry |
index.html |
Entry HTML file |
--css |
link |
CSS mode: link (external files) or style (inline) |
--plugin |
(none) | Plugin identifier (see Plugins for available identifiers) |
--asset-file-name-template |
[name].[ext] |
Emitted asset filename template. Tokens: [name], [hash], [ext] |
--css-public-base |
(none) | Optional base URL/path prepended to Link-mode stylesheet hrefs |
webui serve
Start a development server with live rebuild and HMR.
| Option | Default | Description |
|---|---|---|
APP |
. |
Template/component directory |
--state |
(none) | JSON state file for rendering |
--servedir |
(none) | Static assets directory served at /* |
--port |
3000 |
Server port |
--api-port |
(none) | Proxy API requests; JSON provides buffered state and application/x-webui-stream drives progressive boundaries |
--plugin |
(none) | Plugin identifier (see Plugins for available identifiers) |
--watch |
off | Enable file watching + HMR |
--asset-file-name-template |
[name].[ext] |
Emitted asset filename template. Tokens: [name], [hash], [ext] |
--css-public-base |
(none) | Optional base URL/path prepended to Link-mode stylesheet hrefs |
Features:
- Renders HTML at
/and all route paths - Serves static files from
--servedir - JSON partials for client-side navigation (
Accept: application/json) - HMR polling at
/hmrwhen--watchis enabled - API proxy when
--api-portis set. Backends may return JSON state or a versioned, newline-delimitedapplication/x-webui-streamcontrol response; the CLI retains the Rust renderer, caps precommit output staging at 4,000,000 bytes, and cancels the backend when the browser disconnects.
The control response uses version 2 and exactly three command types:
start is first and supplies the initial object state. Each resume must echo
the pending runtime descriptor's owner, name, and optional string-or-number
key; declarationId may also be supplied for validation. The CLI retains
committed descriptors, so update uses the same target without a reverse
acknowledgement channel. Ambiguous unkeyed update targets are rejected.
The CLI drives the Rust step machine as follows:
| Rust step state | CLI action |
|---|---|
| descriptor present | Wait for the matching backend resume, then call resume |
| no descriptor and not done | Call advance internally |
| done | Complete the browser response |
Rust resume emits only the pending boundary through its checkpoint. The
following internal advance emits parent or tail bytes through the next
descriptor or terminal. The backend does not send an advance control record.
It closes its NDJSON body after sending the resume for the final descriptor;
the CLI's final advance completes the response. There is no terminal control
command.
webui inspect
Convert a compiled protocol to JSON for debugging.
App Layout
my-app/
├── src/
│ ├── index.html # entry template
│ ├── my-card.html # component template
│ └── my-card.css # component styles
├── data/
│ └── state.json # render state
└── dist/ # build output
├── protocol.bin
└── my-card.css
License
MIT