fromcubes-react is a Node-RED module that serves live React applications. You paste JSX straight into the node, it is compiled server-side with esbuild at deploy time, styled with Tailwind CSS 4, and wired to your flows over WebSocket — no build step, no runtime compilation in the browser.
Write plain JSX in the node editor. esbuild bundles React and your code into one file at deploy time.
Utility classes are scanned server-side and served as static CSS. Autocompletion in the editor included. Comes with the fromcubes-tailwind add-on.
The useNodeRed() hook binds msg.payload to React
state and sends events back to the flow. Route to one tab, one user, all logged-in sessions, or everyone.
Define components once in fc-portal-component nodes and reuse them across every portal page.
Chart.js, D3, Three.js, PixiJS… declared per node, auto-installed and bundled at deploy.
A file manager sidebar serves models, textures and fonts at /fromcubes/public/. Comes with the fromcubes-assets add-on.
PostgreSQL, CockroachDB, MySQL, MariaDB, SQL Server, Oracle and SQLite with injection-safe :name parameters. A separate package, fromcubes-db.
Requires Node-RED ≥ 4 and Node.js ≥ 18.5.
The project is split into a core and add-ons. The core,
@aaqu/fromcubes-react, is all you need to build portals; each add-on switches on one extra
feature:
| Module | What it adds |
|---|---|
@aaqu/fromcubes-react |
The core — the nodes, deploy-time bundling, live WebSocket data, the React Editor |
@aaqu/fromcubes-tailwind |
Tailwind CSS 4 for portals, plus class completion in the editor. This guide's example is styled with it. |
@aaqu/fromcubes-assets |
The Portal Assets sidebar: static files served at /fromcubes/public/ |
@aaqu/fromcubes-auth-headers |
Portal users from x-portal-user-* headers set by a reverse proxy (Portal Auth) |
For this guide install the core and Tailwind; add the other two whenever you need them — each switches on by itself once installed. Two ways to install — pick one:
Option A — Palette Manager (no terminal needed). In the editor open
Menu → Manage palette → Install, search for fromcubes and click
install on @aaqu/fromcubes-react, then on @aaqu/fromcubes-tailwind:
@aaqu/fromcubes-portal-react is the old name — skip it.
Option B — npm. Install into your Node-RED user directory (usually ~/.node-red)
and restart Node-RED:
cd ~/.node-red npm install @aaqu/fromcubes-react @aaqu/fromcubes-tailwind # optional: @aaqu/fromcubes-assets @aaqu/fromcubes-auth-headers # restart Node-RED afterwards
Each installed module is listed on its own in Menu → Manage palette → Nodes — the core with its three nodes, each add-on as one plugin — and can be updated or removed there independently.
Three new nodes appear in the palette under the fromcubes category:
portal react, react component and react utility.
Menu → Settings → Fromcubes shows which identity provider and CSS engine the portals use —
whatever add-on is installed, or none without one. There is nothing to set:
@aaqu/fromcubes-portal-react? That old package contained the core
and all three add-ons. Remove it in Manage palette → Nodes (or
npm uninstall @aaqu/fromcubes-portal-react) — it registers the same nodes — then install
@aaqu/fromcubes-react and the add-ons you used (most likely all three, for the same
features as before). Your flows keep working unchanged.
The package ships ready-made examples. In the editor open Menu → Import → Examples → @aaqu/fromcubes-react. Import Shared Components first (it provides the reusable UI building blocks), then Sensor Portal — the example this guide follows end-to-end.
The Shared Components flow contains only fc-portal-component nodes —
Page, Header, Stat, Button and ValueBadge.
Each node holds one React component; once deployed, any portal page can use them as JSX tags.
The Sensor Portal flow is the actual application: an inject node ticks every 2 seconds, a function node generates random sensor readings, and the portal-react node renders them. Anything wired out of the portal node comes from the browser (button clicks, form input).
msg.payload = {
temp: +(18 + Math.random() * 12).toFixed(1),
humidity: Math.round(35 + Math.random() * 40),
pressure: Math.round(995 + Math.random() * 35),
ts: Date.now()
};
return msg;
Double-click the Sensor Portal node. The JSX tab holds the page's
App() component in a Monaco editor with JSX highlighting, Tailwind class completion and tag
completion for your shared components. The URL sub-path field — set in the
Properties tab next to it (here sensors) — decides where the page is served:
/fromcubes/sensors. The box in front of it picks the path prefix — /fromcubes/ by
default, or one you defined in Settings → Fromcubes → Path prefixes, such as
/panel/sensors.
function App() { const { data, send } = useNodeRed(); const s = data || { temp: 0, humidity: 0, pressure: 0 }; return ( <Page> <Header title="Sensor Portal" subtitle="live sensor data" /> <div className="flex-1 flex flex-col items-center justify-center p-8"> <div className="flex gap-10 flex-wrap justify-center"> <Gauge value={s.temp} min={-10} max={50} label="Temperature" unit="°C" /> <Gauge value={s.humidity} min={0} max={100} label="Humidity" unit="%" /> <Gauge value={s.pressure} min={950} max={1050} label="Pressure" unit="hPa" /> </div> <div className="mt-10 flex gap-3 items-center"> <Button onClick={() => send({ action: 'refresh' })}>Refresh</Button> <ValueBadge label="Last" value={s.ts ? new Date(s.ts).toLocaleTimeString() : null} /> </div> </div> </Page> ); }
fc-portal-component nodes. The
bundler injects only the components your JSX actually references (plus their dependencies) — everything else
is tree-shaken away.
The Gauge used by this page is itself a component node living next to the flow — a plain React function component with Tailwind classes and an SVG arc:
Hit Deploy. At that moment fromcubes-react:
/fromcubes/<sub-path> and a WebSocket endpoint next
to it,
Navigate to http://<your-host>:1880/fromcubes/sensors. The gauges animate every two seconds
as the inject node fires; every open tab stays in sync because broadcast messages reach all connected clients.
Clicking Refresh emits a message on the portal node's output wire — check the debug sidebar.
useNodeRed() hookEvery portal page gets one hook that is the whole runtime API:
const { data, topic, send, user, portalClient, authRequired } = useNodeRed();
| Field | Description |
|---|---|
data |
Reactive value of the last msg.payload received on the node's input. Re-renders the
component on every message. Starts as null — nothing is cached server-side, so push
periodically or request initial state with send({}, "init").
|
topic |
The msg.topic of the same message as data, or "" when it had
none.
|
send(payload, topic?) |
Emits a message on the portal node's output wire. The message carries msg._client so
replies can target just this browser tab.
|
user |
Portal auth data forwarded by a reverse proxy (x-portal-user-* headers), or
null.
|
portalClient |
Unique id of this session/tab, assigned by the server — useful for per-client state. |
authRequired |
true when this session is anonymous on a portal with
Authenticated-only delivery enabled — render a login hint instead of an empty page.
|
data holds only the latest payload: messages that arrive faster than React renders
collapse into one render, so a useEffect on data can miss some. Use
data to show current state; for events and request → response replies use the companion hook
useNodeRedMessages, which calls your handler once per message, in order (no replay of earlier
messages on mount):
useNodeRedMessages((payload, { topic }) => { if (topic === "photos") setPhotos(payload); else if (topic === "saved") setSaving(false); });
msg._client intact to
answer one tab, strip portalClient to reach all tabs of one user, set
msg._client = { authenticated: true } to reach every logged-in session, or omit
msg._client entirely to broadcast.
x-portal-user-* identity headers, and anonymous visitors
receive a one-time auth_required frame (surfaced as authRequired above). Force a
true broadcast with msg._client = { authenticated: false }.
/fromcubes/public/<path>.