Tokra builds desktop apps with a Ruby backend and a web frontend. It is a port of Tauri to Ruby: your Ruby code runs in the app's process, and your HTML, CSS, and JavaScript run in the operating system's web view.
A Ruby developer who wants a desktop app usually has to change stacks.
Electron ships Chromium and Node.js inside
every app, and you write the backend in JavaScript. Tauri uses the
system's web view, and you write the backend in Rust.
Glimmer DSL for LibUI
keeps you in Ruby but draws native widgets, so you leave HTML behind.
Tokra keeps both Ruby and HTML. Your Rack
app, whether Rails, Roda, or a lambda, answers the window's requests for
tokra:// URLs inside the process. No web server runs, and no port opens.
The page calls Ruby through Tauri's JavaScript API.
Tokra follows Tauri 2.9.5: its class and method names, its config file, its error messages, and its IPC wire format. Tauri's crates for windows and web views, tao and wry, do the native work through a Rust extension that compiles when you install Tokra. Everything else, from the IPC router to the config reader, is Ruby.
This app is three files in one folder: a config that describes one window, an icon, and a script that serves a page and answers one command from it.
tokra.conf.json:
{
"identifier": "com.example.hello",
"productName": "Hello",
"app": {
"withGlobalTauri": true,
"windows": [{ "title": "Hello", "width": 480, "height": 320 }]
}
}icons/icon.png is the window's icon, as in a Tauri app. Any PNG with
an alpha channel (RGBA) works. To borrow the one from Tokra's examples:
curl -fsSL --create-dirs -o icons/icon.png \
https://raw.githubusercontent.com/setdef/Tokra/trunk/examples/verify_ping_pong/icons/icon.pngapp.rb:
require "tokra"
PAGE = <<~HTML
<h1>Hello from Tokra</h1>
<button onclick="greet()">Greet</button>
<p id="answer"></p>
<script>
async function greet() {
const answer = await window.__TAURI__.core.invoke("greet", { name: "Ada" });
document.getElementById("answer").textContent = answer;
}
</script>
HTML
site = ->(_env) { [200, { "content-type" => "text/html" }, [PAGE]] }
Rack::Handler::Tokra.run(
site,
invoke_handler: Ractor.shareable_proc { |invoke|
next false unless invoke.command == "greet"
invoke.resolve("Hello, #{invoke.payload["name"]}!")
true
}
)Run it with bundle exec ruby app.rb, after the steps in
Installation. A 480 by 320 window titled "Hello" opens
and shows the page. Click Greet: the page sends the greet command
to Ruby, the handler answers, and "Hello, Ada!" appears under the button.
Close the window, and the process exits.
Rack::Handler::Tokra.run reads the config, opens each window its
app.windows lists, sends each request from those windows to site, and
runs until the last window closes. withGlobalTauri puts Tauri's
JavaScript API on window.__TAURI__, so a page without a bundler can
call it. The handler answers true for a command it took and false
for one it didn't; for those, the page's promise rejects with
Command NAME not found.
Tokra runs on macOS, Windows, and Linux. CI runs its tests on all three,
for every change, on GitHub's macos-latest (Apple silicon),
windows-latest, and ubuntu-latest runners.
| macOS | Windows | Linux | |
|---|---|---|---|
| Ruby | 4.0.1 or newer, 4.1's preview included | 4.0.1 or newer, from RubyInstaller; 4.1 as its build of Ruby's master until it releases 4.1.0 | 4.0.1 or newer, 4.1's preview included |
| Rust | 1.88 or newer | 1.88 or newer, GNU toolchain (x86_64-pc-windows-gnu) |
1.88 or newer |
| Web view | WKWebView | WebView2 | WebKitGTK 4.1, version 2.40 or newer |
| To build | the Xcode Command Line Tools | libclang and RubyInstaller's MSYS2 tools | libwebkit2gtk-4.1-dev, libgtk-3-dev, libxdo-dev, libclang-dev, pkg-config |
| To run | nothing more | the WebView2 runtime | libxdo3 for menus; libayatana-appindicator3-1 for tray icons |
The Linux package names are Debian's and Ubuntu's. On Arch, libxdo comes
with xdotool and the tray library is libayatana-appindicator. Without
an AppIndicator library, building a tray icon raises Tokra::Error::Tray.
RubyInstaller's Ruby is a MinGW build, and rb-sys refuses to compile
against it with Rust's MSVC toolchain. The
CI workflow shows a full Windows setup,
including where clang finds Ruby's headers. Some plugins need more; see
Plugins.
Cargo builds exactly the Rust crate versions in Tokra's Cargo.lock and
fails rather than resolve newer ones. To build against newer versions
anyway, set RB_SYS_EXTRA_CARGO_ARGS (for example to an empty string);
it replaces --locked.
Tokra ports Tauri piece by piece. These parts of Tauri are not available yet:
- Capabilities. Tokra has no permission system. Pages your app serves
(
tokra://localhost, orhttp://tokra.localhoston Windows) can call every command. Pages from any other origin are refused withCommand NAME not allowed by ACL. - JavaScript APIs for windows, web views, the app, and paths. From the
page, Tauri's
core(commands),event,menu,tray, andimageAPIs work. Control windows from Ruby. devUrlandfrontendDist. Tokra reads both from the config, but loads pages only from a Rack app or a protocol you register, not from a dev server or a folder of built files.- TOML configs. The config is JSON or JSON5.
- The
tokracommand and app bundles. See Shipping your app. - iOS and Android. Tokra runs on desktop systems only.
Install the build requirements from Compatibility first.
RubyGems.org has tokra 0.0.1.pre.2, from January 2026, which predates
everything in this README. Until the next release, build Tokra from a
clone of this repository:
git clone --recurse-submodules https://github.com/setdef/Tokra.git
cd Tokra
bundle install
bundle exec rake compilerake compile builds the Rust extension and copies Tauri's JavaScript
from the vendor/tauri submodule into lib/tokra/js/.
Then point your app's Gemfile at the clone. This one assumes the clone
sits beside your app's folder. Tokra reads URLs with
ferro-url, a Ruby binding of the Rust
url crate that Tauri uses. It is not on RubyGems.org yet, so take it
from its release tag:
source "https://rubygems.org"
gem "tokra", path: "../Tokra"
gem "ferro-url", git: "https://github.com/setdef/Ferro",
tag: "ferro-url/v0.1.2", glob: "gems/url/*.gemspec"Run bundle install in your app's folder. Bundler compiles ferro-url's
Rust extension as it installs the gem.
tokra.conf.json is Tauri's tauri.conf.json under Tokra's name, with
the same keys, so
Tauri's configuration reference
documents it. Every app needs one, and it needs an identifier, a
reverse domain name such as com.example.notes. Without one, Tokra
raises missing field `identifier` before any window opens.
Tokra looks for the file beside the script you run, even if the script
changes directory later. A tokra.macos.conf.json,
tokra.windows.conf.json, or tokra.linux.conf.json beside it is
merged over it on that platform. For JSON5, with its comments and
trailing commas, name the files tokra.conf.json5 and
tokra.macos.conf.json5 instead. To keep the config elsewhere, pass its
path: Tokra.generate_context("config/tokra.conf.json").
The config's app.windows lists the windows the app opens at start, with
any of Tauri's window keys (title, width, height, resizable,
decorations, and the rest). A config that lists no windows opens none.
The window icon is icons/icon.png beside the config, or the first PNG
the config's bundle.icon lists. It must be an RGBA PNG. Without it,
Tokra raises failed to open icon PATH before any window opens, where
Tauri fails to compile.
Pass Rack::Handler::Tokra.run any Rack app. For Rails, pass
Rails.application:
ENV["RAILS_ENV"] = "production"
require_relative "config/environment"
Rack::Handler::Tokra.run(Rails.application)examples/verify_rails_sqlite is a stock
Rails 8.1 to-do app (SQLite, Turbo, import maps) that runs this way. Its
README lists the three settings a Rails app changes for the desktop and
how it keeps its secret_key_base.
examples/verify_ping_pong does the same
with a Roda app that submits a form, follows a redirect, and calls Ruby
from the page.
Rack::Handler::Tokra.run builds a Tokra::Builder for you. Build one
yourself to add a setup hook, menus, tray icons, event listeners, or
plugins, as you would in a Tauri app's main. With site from the
first app:
require "tokra"
require "tokra-dialog"
app = Tokra::Builder.default
.app(site)
.plugin(Tokra::Plugins::Dialog.init)
.setup(&Ractor.shareable_proc { |app| puts "#{app.config.product_name} is running" })
.build(Tokra.generate_context)
app.runTokra.generate_context reads the config, as Tauri's
generate_context!() does when a Tauri app compiles. Builder#build
makes the app from it, and App#run opens the config's windows, calls
the setup hook, and runs the event loop. Builder#run(context) does
both steps at once.
Wrap each block you give the Builder, and the invoke_handler, in
Ractor.shareable_proc. Given a plain block, the Builder raises
setup block must be Ractor-shareable (use Ractor.shareable_proc), and
Ractor.shareable_proc raises Ractor::IsolationError for a block that
refers to a mutable object outside it. Keep such objects in managed
state: Builder#manage(object), then app.state(ObjectClass).
App#run never returns. When the app exits, it raises SystemExit with
the exit code, so ensure clauses and at_exit hooks run, but code after
the call does not. Put shutdown work in a handler for
Tokra::RunEvent::Exit.
Each of Tauri's official plugins that Tokra ports is a separate gem, in
plugins/. The ones with a frontend package serve Tauri's
commands, so the package works unchanged. Import a package through your
bundler and serve the bundle from your Rack app; the plugins' APIs are
not on window.__TAURI__.
| Gem | Tauri plugin | Frontend package | Ferro gems it needs |
|---|---|---|---|
| tokra-clipboard | clipboard-manager | @tauri-apps/plugin-clipboard-manager |
ferro-arboard |
| tokra-dialog | dialog | @tauri-apps/plugin-dialog |
ferro-rfd |
| tokra-global-shortcut | global-shortcut | @tauri-apps/plugin-global-shortcut |
ferro-global-hotkey |
| tokra-log | log | @tauri-apps/plugin-log |
ferro-time |
| tokra-notification | notification | @tauri-apps/plugin-notification |
ferro-notify-rust, ferro-url, ferro-time |
| tokra-process | process | @tauri-apps/plugin-process |
none |
The plugins are pure Ruby, but the Ferro
gems they build on compile Rust extensions. On Linux, ferro-rfd also
needs libwayland-dev and pkg-config to build. Each plugin's README
covers its install, its usage, and how it differs from Tauri's plugin.
Neither the plugins nor the Ferro gems are on RubyGems.org yet. Take the plugins from your clone as you take Tokra, and each Ferro gem from its release tag. For the dialog plugin:
gem "tokra-dialog", path: "../Tokra/plugins/dialog"
gem "ferro-rfd", git: "https://github.com/setdef/Ferro",
tag: "ferro-rfd/v0.1.0", glob: "gems/rfd/*.gemspec"Keep each Ferro line's glob to that gem's folder. With a wider glob,
Bundler can take other Ferro gems from the wrong tag.
There is no tokra command yet. Packaging an app for people who don't
have Ruby is planned through Fledge.
Today you run a Tokra app with bundle exec ruby.
- API reference. In your clone,
bundle exec rake rdocwrites it totmp/rdoc/index.html. Most classes name the Tauri type they mirror. - Tauri's configuration reference
documents every key of
tokra.conf.json. - Tauri's JavaScript API reference documents what your page calls. See Compatibility for the parts Tokra serves.
- CHANGELOG.md lists the changes you can observe since the last release, with breaking ones marked.
- examples/ holds three apps: a static page served through Tokra's low-level native classes, a Roda app, and a Rails app.
- The plugin READMEs, linked under Plugins, cover each plugin's install, usage, and differences from Tauri.
Ask questions and report problems on the
Tokra forum. Include your operating
system and its version, the output of ruby -v and rustc -V, the
command you ran, and its full output. GitHub Issues are open to the
project's collaborators only.
Report a security problem privately, as SECURITY.md says, never on the forum.
To send a patch, post it on the forum, or email it with git send-email to
replies+tokra@forum.setdef.com. git-send-email.io
shows how to set that up.
Start with AGENTS.md. It holds the rules for people and
agents alike, from where Tauri's source lives to the full check suite,
bundle exec rake, that every change passes. Everyone who takes part
follows the code of conduct.
Tokra and its plugins are licensed under the GNU Affero General Public License, version 3 or later. Code adapted from Tauri keeps Tauri's license, Apache-2.0 OR MIT. The documentation is CC-BY-SA-4.0. The code snippets in this README are MIT-0, so you can copy them into your app under any license. Every file names its license, the REUSE tool checks it, and the texts are in LICENSES.
Tokra's maintainer describes the three ways code and prose come to exist like this:
I use three words for how code and prose comes to exist. Code or prose I wrote, I typed by hand, with nothing generated. Code or prose I wrought, an AI agent generated while I iterated with it, and I reviewed every change before committing it, so I take responsibility for every diff. Code or prose I requested, an agent built with little or no review from me, in the style of a "dark factory."
Tokra's early work was wrought; the rest is requested. AI agents generated its code, tests, and documentation, this README included, under the rules in AGENTS.md, and commits name the model in their footer. For the requested work, independent agent reviews and the gate that CI runs stand in for the maintainer's review: tests against real windows on Linux, macOS, and Windows, plus RuboCop, Steep, RBS, RDoc coverage, Clippy, REUSE, and a check that loads each packaged gem outside the repository. On declare-ai.org's scale the assistance is creative, not none, non-creative, or total, because the agents made design and wording choices under the maintainer's direction.