Overview
The node adapter, flare.json config, and app.run() for long-lived Node.js servers.
AI generated, pending review
Node.js is the default Flare target. The node adapter reads flare.json from the project root (with FLARE__* environment overrides), supports host.singleton() for process-lifetime services, and returns an app with run() for a long-lived HTTP and WebSocket server.
Minimal app
Section titled “Minimal app”import { FlareHost, FlareResponse } from "@flare-ts/core";import { node } from "@flare-ts/core/node";
const host = new FlareHost(node);
host.http.get("/health", () => new FlareResponse(200, { ok: true }));
const app = host.build();app.run();app.run() runs startup hooks, binds the server, and moves host.state to "ready" when the socket is listening. WebSocket upgrades on the same port are handled when you register host.ws routes.
Config
Section titled “Config”A missing flare.json on Node is logged, not fatal: defaults plus env fill in. See Configure your app and flare.json reference.
What Node supports
Section titled “What Node supports”| Feature | On Node |
|---|---|
host.singleton() | Yes |
host.scoped() | Yes |
host.ws channels | Yes (process-wide broadcast domain) |
host.durableObject() | No (Workers only) |
| Graceful shutdown | Yes via NodeRunHandle.stop() |
Related
Section titled “Related”- Run and shutdown: ports, drain, SIGTERM
- Lifecycle:
host.statestate machine - Install: Node version and packages