openui-rails
Render streaming, interactive OpenUI Lang interfaces inside an existing Rails application. Use Rails views and Stimulus to mount the official browser runtime; keep authentication, authorization, and persistence in Rails.
Unofficial integration: this project is not affiliated with or maintained by Thesys. It uses the OpenUI JavaScript runtime and does not implement a Ruby parser or renderer.
Documentation · RubyGems · Roadmap
What you get
- A view helper and Stimulus bridge for rendering server-owned surfaces.
- A shared library fingerprint for the prompt, browser runtime, and stored UI.
- Ordered stream envelopes with gap detection over Turbo Streams or Action Cable.
- One allowlisted action endpoint with authorization, validation, and replay protection.
- An optional RubyLLM streaming adapter.
Your app supplies scoped record lookup, stream subscriptions, and snapshot recovery. Multi-process apps can opt into the SQLite shared idempotency store.
Get started
Requires Ruby 3.2+ and Rails 8.0 or 8.1. On Rails 8.0, use json < 3.
The runtime-fetch task also needs npm. RubyLLM is optional.
# Gemfile
gem "openui-rails", "~> 0.9.0"bundle install
bin/rails generate openui:install
bin/rails openui:runtime:fetch
bin/rails openui:library:prepare
bin/rails openui:doctorFollow Getting Started to register the Stimulus controllers and include the stylesheet. After setup, render a surface from an ERB view:
<%= openui_surface(
surface: { id: "support-42", response: 'root = TextContent("How can I help?")' },
label: "Support"
) %>Actions are denied until you configure authorization.
Documentation and development
The documentation site contains the full guides and API reference:
Version 0.9.0 freezes the candidate API for 1.0 and fixes stream and recovery defects.
See What's New for the upgrade and
Supported API for the compatibility boundary.
The API may change during 0.x; see the
changelog and the proposed path to 1.0.
The site's stable channel follows the latest release; /next/
follows main.
For repository work, use Contributing, Releasing, and the 0.9.0 release record. Report vulnerabilities through the security policy.
License
MIT. See third-party notices before redistributing the OpenUI browser bundle.