Skip to main content

Crate webui_node

Crate webui_node 

Source
Expand description

Node.js native addon for the WebUI framework via napi-rs.

Provides high-performance server-side rendering by compiling the Rust WebUI handler directly into a .node native addon — no C ABI intermediary.

The render function accepts pre-compiled protobuf protocol data (from webui build) and streams rendered HTML fragments via a callback, enabling true streaming SSR without buffering the entire response.

§Usage (from Node.js)

import fs from 'node:fs';

// Load the native addon
const mod = { exports: {} };
process.dlopen(mod, './target/release/libwebui_node.dylib');
const { render } = mod.exports;

// Read pre-compiled protocol (from `webui build`)
const protocol = fs.readFileSync('./dist/protocol.bin');
const state = '{"name": "WebUI"}';

// Stream rendered fragments
render(protocol, state, (chunk) => process.stdout.write(chunk));

Structs§

JsBuildOptions
Build options for the webui build API.
JsBuildResult
Result of a successful build operation.
JsBuildStats
Build statistics returned from the build function.

Functions§

build
Build a WebUI application from an app directory.
inspect
Inspect protocol bytes and return a JSON representation.
render
Render a pre-compiled WebUI protocol with JSON state, streaming each fragment to the provided callback.
render_component_templates
render_partial
Produce a complete JSON partial response for client-side navigation.