Skip to content

Overview

The node adapter, flare.json config, and app.run() for long-lived Node.js servers.

AI generated, pending review Updated 10 days ago · Flare 0.3

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.

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.

A missing flare.json on Node is logged, not fatal: defaults plus env fill in. See Configure your app and flare.json reference.

FeatureOn Node
host.singleton()Yes
host.scoped()Yes
host.ws channelsYes (process-wide broadcast domain)
host.durableObject()No (Workers only)
Graceful shutdownYes via NodeRunHandle.stop()