Skip to content

The Open Standard for Generative UI

2.6 KB
Raw Blame

@openuidev/browser-bundle

Prebuilt browser bundle for OpenUI's React renderer and UI library. It packages @openuidev/react-lang, @openuidev/react-ui, React, ReactDOM, and runtime dependencies into one script plus one stylesheet.

Intended for iframe, CDN, and no-build-pipeline contexts where ESM/CJS module resolution isn't available and you just want a <script> tag that gives you the OpenUI renderer and component library.

Links: OpenUI docs | GitHub repo

Example consumers:

  • Open WebUI tool plugins that inject sandboxed HTML via HTMLResponse
  • Embeddable chat widgets on static sites
  • Quick demos and CodePen-style prototypes

For any build-pipeline project, use @openuidev/react-lang and @openuidev/react-ui directly.

Install

You almost certainly want to use the CDN. jsDelivr and unpkg both auto-publish from npm. Version 0.2 bundles react-lang 1.0 and react-ui 0.18, so it renders OpenUI Lang 1.0; pair it with a system prompt from lang-core 1.x:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/@openuidev/[email protected]/dist/openui-styles.css"
/>
<script src="https://cdn.jsdelivr.net/npm/@openuidev/[email protected]/dist/openui-bundle.min.js"></script>

Public API

The bundle attaches a single global:

window.__OpenUI = {
  React,              // react
  createRoot,         // react-dom/client
  Renderer,           // @openuidev/react-lang
  openuiChatLibrary,  // @openuidev/react-ui/genui-lib, a Library
};

This shape is a stable public contract. Any change to the keys or their exported values is considered breaking and bumps the major version of this package.

Usage

<div id="root"></div>
<script>
  const { React, createRoot, Renderer, openuiChatLibrary } = window.__OpenUI;

  const response = "..."; // OpenUI Lang from your LLM / backend

  createRoot(document.getElementById("root")).render(
    React.createElement(Renderer, { response, library: openuiChatLibrary }),
  );
</script>

Size

  • openui-bundle.min.js: ~3.2 MB raw / ~900 KB gzipped
  • openui-styles.css: ~320 KB raw / ~35 KB gzipped

All dependencies are inlined; there are no runtime fetches beyond the two files above.

Rebuilding locally

pnpm install
pnpm --filter @openuidev/browser-bundle build

This produces dist/openui-bundle.min.js and dist/openui-styles.css.

Documentation