Your first widget
Every development build of Toolblox includes Hello, world!, a small working widget to start
from. It adds a page with two stat tiles and a button, built from the same components the app
uses. This tutorial walks through it, turns a copy of it into your own widget, and covers what
happens between a folder appearing and activate running, how to pick up code changes, where your
log lines go, and how to get the app back when a widget breaks it.
Hello, world! is about 40 lines. Later tutorials expand on it: pages and screens, slots and styles, storage and state, and processes.
What a module widget is
Section titled “What a module widget is”A module widget is a folder (later, a ZIP package) with two required files:
widget.json, the manifest. It names the widget and declares"module": "main.js".main.js, an ES module that exportsactivateand, optionally,deactivate.
Toolblox imports main.js into the app window itself, not into a sandboxed frame, and calls
activate with the host API object. That object gives the widget the app’s React instance, the
app’s UI components, live app state, navigation, storage, logging, and every
IPC method with all permissions granted. Module widgets are
full-trust by design: safety comes from catalogue review, signed and hash-pinned packages, safe
mode, and error boundaries, not from limits on the API. The one thing a widget never receives is a
Roblox session cookie; those stay in Rust for widgets and for the Toolblox interface alike.
Hello, world! lives in
examples/hello_world/.
Before you start
Section titled “Before you start”You need a development build of Toolblox. Release builds only load widgets installed from the signed catalogue, so an unpacked folder never loads in a downloaded copy of the app. See Development for prerequisites; the short version is:
npm installnpm run tauri devnpm run tauri dev compiles the Rust host in debug mode and starts the Vite dev server for the
interface. Debug builds differ from release builds in three ways that matter here:
- They skip the startup update check, so the app opens straight away.
- They report the
canarychannel, which shows the widgets folder at the bottom of the Widgets page and a-canarysuffix on the version in the sidebar. - They accept widget folders without the
.installed.jsonrecord that catalogue installs write. A release build rejects such a folder with “Widget … is missing install metadata.”
Find the widgets folder
Section titled “Find the widgets folder”Widgets live in the widgets folder inside the Toolblox data folder:
| Platform | Widgets folder |
|---|---|
| Windows | %LOCALAPPDATA%\Toolblox\widgets |
| macOS | ~/Library/Application Support/Toolblox/widgets |
In a development build you don’t need to remember this: open Widgets in the sidebar and scroll to the bottom. A panel reads “Development builds also load unpacked widgets from this folder.” with the exact path and a copy button.
Debug builds also honour the TOOLBLOX_DATA_DIR environment variable. When it’s set, Toolblox
uses that folder as its data folder, so widgets live in $TOOLBLOX_DATA_DIR/widgets. This is
useful for keeping test accounts, settings, and widget data apart from the copy of Toolblox you use
day to day. Accounts’ Roblox sessions are still kept in the operating system’s credential store.
$env:TOOLBLOX_DATA_DIR = "$HOME\toolblox-dev-data"npm run tauri devTOOLBLOX_DATA_DIR="$HOME/toolblox-dev-data" npm run tauri devMeet Hello, world!
Section titled “Meet Hello, world!”The first time a development build starts, it adds Hello, world! to the widgets folder. It
appears in the Installed section of the Widgets page, enabled, and in the sidebar under
Widgets. Select it to open its page, titled “Hello, world!” The title is the name in
widget.json; the page itself is empty.
Toolblox adds it only once, and records that in a hidden .example-added file in the widgets
folder. Uninstalling it sticks. To get it back, install it from the Catalogue section, which in
development builds lists the repository’s example and catalogue widgets (see
Testing the catalogue locally).
Release builds never include it.
Directorywidgets/
Directoryhello_world/
- widget.json
- main.js
- LICENSE
The manifest, widget.json:
{ "schemaVersion": 1, "id": "hello_world", "name": "Hello, world!", "version": "1.0.0", "description": "The example widget in development builds. Start a new widget from it.", "module": "main.js"}Each field is checked by WidgetManifest::validate in
src-tauri/src/widgets.rs:
schemaVersionmust be1.idis 1 to 64 lowercase letters, digits, and underscores. Hyphens and capitals are rejected. The folder name must be identical to it: Toolblox finds the manifest by scanning every folder, but serves the module from<widgets folder>/<id>/main.js.nameis 1 to 80 characters. It’s the sidebar label and the page title.versionmust be valid SemVer, such as1.0.0.1.0is rejected.modulemust be exactlymain.jsat the package root. Other names and paths are rejected.
Hello, world! needs no permissions, so it declares none. Module widgets receive every permission at run time regardless, but the catalogue requires the declared list to match what the widget does, and the install dialog shows it to the user. The Manifest reference covers every field.
The module, main.js:
export function activate(toolblox) { toolblox.registerPage(function HelloPage() { return null; });}
export function deactivate() {}A few things in this file are deliberate:
- Content comes from
toolblox.React. To render something, usetoolblox.React.createElement, often shortened toh. The widget doesn’t import or bundle React. It uses the app’s own React instance, which is what makes hooks such asReact.useStatework inside the app’s component tree. A second copy of React breaks hooks with “Invalid hook call”. activateregisters, components render.activateis a plain function that runs once.HelloPageis a React component that Toolblox renders whenever the page is open, so hooks such astoolblox.useAppState()andReact.useStatebelong in it, never inactivate.- The component is a named function. React shows
HelloPagein error messages and in the component stack that Toolblox writes to the log when a render fails. toolblox.uihas the app’s own components. Use them, such astoolblox.ui.Button, so a widget matches the app and follows custom themes without its own styles. When you add class names, use ones the app already uses: Tailwind CSS is compiled into the app ahead of time, and a class that doesn’t exist does nothing, silently. See Slots and styles for shipping your own CSS.deactivateis optional. Toolblox removes every page, settings page, slot contribution, stylesheet, and state listener a widget registered when it unloads the widget, sodeactivateis only for things Toolblox doesn’t track, such as timers. The storage and state tutorial uses it.
Make it your own
Section titled “Make it your own”-
Copy the folder. In the widgets folder, copy
hello_worldto a folder named after your widget’s ID, such asmy_widget. Keephello_worldas a reference. -
Rename it. In the copy’s
widget.json, setidto the folder name, and give it its ownnameanddescription. Keepversionat1.0.0until you publish. -
Bring Toolblox to the front. Toolblox reloads its state when the window gains focus, every 60 seconds, and after most actions. Your widget appears next to Hello, world!, enabled.
New folders are enabled by default because Toolblox stores the list of disabled widgets, not enabled ones. Turning the switch on a widget’s card off adds it to that list, unloads the module, and stops any processes it started.
-
Change the page. In the copy’s
main.js, makeHelloPagereturn content, then reload the window:return toolblox.React.createElement("p", null, "Hello, world!"); -
Add to the app outside your page. Widgets can add to existing screens through slots. Add this to
activateto put a badge under every account’s name on the Accounts page:const h = toolblox.React.createElement;toolblox.addToSlot("accounts.row", () => h(toolblox.ui.Badge, { variant: "outline" }, "Hello"));The slots and styles tutorial covers every slot.
From here, each tutorial adds one capability to the same widget: a settings page and tabs in pages and screens, saved data in storage and state, and helper programs in processes. When it’s ready, list it with one pull request.
What happens when the widget loads
Section titled “What happens when the widget loads”Knowing the path from folder to activate makes failures much easier to place. Each step names the
code that runs it.
- Discovery.
get_app_stateinsrc-tauri/src/app_commands.rscallsdiscover_installed, which reads every folder in the widgets folder whose name doesn’t start with.. For each one it readswidget.json(at most 128 KB), parses it, and validates it. A folder that fails produces an entry inwidgetErrors, which the Widgets page shows as a red panel above the Installed section. - Summary. Each valid widget becomes a
WidgetSummaryin app state. ItsmoduleUrlpoints at the widget’s custom protocol:http://widget.localhost/hello_world/main.json Windows, where WebView2 serves custom schemes over HTTP, andwidget://localhost/hello_world/main.json macOS. The protocol handler inwidget_protocol.rsonly serves files that resolve inside the widget’s folder, only to the main window, and withCache-Control: no-store. - Session. The app shell calls
syncWidgetModulesinsrc/widgets/host.tsxwhenever the set of enabled module widgets changes. For each newly enabled widget it callsopen_widgetwith themodulesurface. Rust creates a session with a random ID and every permission, because modules run in the app window.toolblox.requestsends that session ID with each IPC call. If the session can’t be opened, the module still loads, and everyrequestcall throws “The widget session isn’t open.” - Import. The shell runs
import(moduleUrl). The app’s Content Security Policy allows scripts from the widget origin, so the module and anything it imports from its own folder load. - Activation. The shell builds the host API for this widget with
createApiand callsactivate(toolblox). It awaits the returned promise, so anasyncactivate can load stored data before it registers anything. - Rendering.
registerPagestoresHelloPagein the widget registry and notifies the shell, which re-renders. When the route is/widgets/hello_world, the shell renders the component inside an error boundary.
If the import or activate throws, Toolblox writes “Module failed to load: …” with the stack to the
log under widget:hello_world, and the widget’s card shows Failed to load with the error in its
tooltip. Contributions registered before the throw stay registered.
Change the code and reload
Section titled “Change the code and reload”Edit main.js, for example make HelloPage return toolblox.React.createElement("p", null, "Hello again."). Then:
- Open the developer tools. Development builds enable them: right-click anywhere in the window and select Inspect.
- With the developer tools focused, press Ctrl+R on Windows or
Cmd+R on macOS, or run
location.reload()in the console.
The window reloads, the startup gate passes immediately because Rust already finished it, and every enabled widget is imported fresh.
Changes to widget.json, such as a new name or description, need no reload. They appear on the
next state load, for example when the window regains focus. Changing the id also needs the folder
renamed to match.
Read the logs
Section titled “Read the logs”Toolblox writes one log for the app and its widgets: logs/toolblox.log in the data folder,
rotated at 1 MB with three older files kept. To read it, open Settings, find Diagnostics,
and select View next to Logs. The page shows the whole log, newest first; Copy copies it
and Open folder opens the log folder.
The widget’s records use the target widget:<id>. Add a log line to activate:
void toolblox.log.info("Activated");After a reload, the log reads:
2026-10-14T09:12:09.880Z INFO widget:hello_world: Activatedtoolblox.log has debug, info, warn, and error. Each returns a promise that never rejects.
Development builds keep debug lines; release builds keep info and above. Besides your own
lines, Toolblox writes these under your widget’s target:
- “Module failed to load: …” when the import or
activatethrows; - “Render failed: …” with the React component stack when a contribution throws while rendering;
- “Deactivate failed: …” when
deactivatethrows; - “Request
<method>failed: …” when an IPC request returns an error; - process starts and stops, and the first 200 lines of each process’s error output.
Before a line is written, Toolblox removes Roblox session cookies, join tickets, launch links, and
the values of keys such as authorization, cookie, token, and password, and cuts messages
over 8 KB. Redaction is a safety net; don’t log secrets. console.log output only goes to the
developer tools console and isn’t kept. See
Logs and failures for the full rules.
When a widget breaks
Section titled “When a widget breaks”Every contribution renders inside an error boundary. Make HelloPage throw to see it:
toolblox.registerPage(function HelloPage() { throw new Error("Not yet");});After a reload, the page shows an inline alert, “Hello, world! failed to render. (Error: Not yet)”, in place of the widget’s content, and the rest of the app keeps working. The log gets a “Render failed” line with the component stack.
Error boundaries can’t help with everything a full-trust module can do. An infinite loop in
activate, a stylesheet that hides the sidebar, or a replaced screen with no way back can make the
app unusable. Safe mode starts Toolblox with every widget off for one session:
-
From a terminal, start Toolblox with
--safe-mode. For a development build, arguments after a second--reach the app:Terminal window npx tauri dev -- -- --safe-mode -
From the data folder, create an empty file named
safe-mode-next-launchin the data folder, then start Toolblox. It deletes the file as it reads it.
In safe mode a banner reads “Safe mode. Widgets are off for this session.” No module is imported,
open_widget refuses every surface, and no widget processes start with the app. The Widgets page
still works, so you can turn the broken widget off, then select Restart normally.
While developing you can also hide a widget from Toolblox without deleting it: rename its folder so
it starts with a dot, such as .hello_world. Discovery skips hidden folders.
Write it with JSX
Section titled “Write it with JSX”Calling createElement by hand gets unwieldy past a few components. Any bundler that can set the
JSX factory works, as long as the factory is the app’s React. The approach below uses
esbuild and keeps the source in src/, building main.js at the
widget root.
Directoryhello_world/
- widget.json
- main.js (built)
- package.json
Directorysrc/
- host.js
- main.jsx
- HelloPage.jsx
host.js holds the host API in live bindings that every other file imports. ES module exports are
live, so the values assigned in bind are visible to every importer, and esbuild preserves that
when it bundles.
export let toolblox;export let React;export let ui;
export function bind(api) { toolblox = api; React = api.React; ui = api.ui;}A file that contains JSX imports React from host.js, which puts it in scope for the JSX
factory:
import { React } from "./host.js";
export function HelloPage() { return <></>;}import { bind, toolblox } from "./host.js";import { HelloPage } from "./HelloPage.jsx";
export function activate(api) { bind(api); toolblox.registerPage(HelloPage);}
export function deactivate() {}{ "private": true, "scripts": { "build": "esbuild src/main.jsx --bundle --format=esm --target=es2022 --jsx-factory=React.createElement --jsx-fragment=React.Fragment --outfile=main.js", "watch": "npm run build -- --watch" }, "devDependencies": { "esbuild": "^0.25.0" }}Run npm install once, then npm run watch while you work and reload the Toolblox window after
each rebuild. The output must be a single ES module (--format=esm) that exports activate, and
--bundle inlines your other files so main.js doesn’t depend on src/.
Notes on this setup:
--jsx-factory=React.createElementcompiles<div />toReact.createElement("div"), using whateverReactis in scope. Because components only render afteractivatehas calledbind,Reactis always set by then.- Don’t
import React from "react"anywhere, and don’t depend on packages that do. The bundle would then contain a second React, and hooks would fail with “Invalid hook call”. - App components work in JSX as
<ui.Button>, because JSX treats a dotted name as a component reference. - TypeScript works the same way: esbuild compiles
.tsxfiles with the same flags. Toolblox doesn’t publish a types package; the API’s shape iscreateApiinsrc/widgets/host.tsx, documented on Host API. - Leave
package.json,src/, andnode_modules/out of the package you publish. See Packaging.
Common mistakes
Section titled “Common mistakes”| Symptom | Cause |
|---|---|
| The widget doesn’t appear, and the Widgets page shows “Widget … couldn’t load: …” | The manifest failed validation. The message names the rule, such as “The widget version isn’t valid SemVer.” |
| The widget doesn’t appear and there’s no error | The folder name starts with ., the folder isn’t directly inside the widgets folder, or the window hasn’t regained focus since you added it. |
| The card shows Failed to load | The import or activate threw. Check the log for “Module failed to load”. A folder name that doesn’t match the id causes a failed import. |
| “Invalid hook call” | A hook ran in activate instead of a component, or the bundle contains its own React. |
| Code changes don’t show | The window wasn’t reloaded. Toggling the widget reuses the cached module. |
| Styles don’t apply | The Tailwind class isn’t used anywhere in the app, so it isn’t compiled. |
fetch() fails with a Content Security Policy error |
The app’s policy only allows connections to the Rust host. Use toolblox.request("network.fetch", …). |
| The widget works in development but a release build rejects it | Release builds load only catalogue installs. See Publishing. |
Next steps
Section titled “Next steps”- Pages and screens adds a settings page, tabs, and a replacement Dashboard.
- Host API lists every member of
toolblox.