Browse docs

SDKs Node.js SDK

Node.js SDK

@superflows/sdk for Node.js 18 and later. No dependencies; one line to start.

Install

bash
1npm install @superflows/sdk
js
1// first line of your entry file
2require("@superflows/sdk").init({ service: "checkout-api" });

Frameworks

FrameworkSetup
Express 4 and 5Nothing else.
Next.js 15 (app router)Call init from instrumentation.js when NEXT_RUNTIME === "nodejs".
Fastify, Koasuperflows.instrument(app) right after creating the app.
Plain http / httpsRequests are counted; without a framework they appear as <unmatched>.

API

CallWhat it does
init(options?)Starts Superflows. Never throws; a bad config prints one line and disables the SDK.
health(fn)Your own deep check, run with each heartbeat. Return false or throw → DEGRADED. 2-second timeout.
flush(ms)Sends what is buffered; for short-lived processes. Resolves true when everything was sent.
instrument(app)Route labels for Fastify and Koa.

Configuration

VariableMeaning
SUPERFLOWS_KEYIngest key (also read from .env). Required except against superflows dev.
SUPERFLOWS_ENDPOINTDefaults to https://ingest.superflows.cloud. Use http://localhost:4318 with superflows dev.
SUPERFLOWS_ENVEnvironment name; falls back to NODE_ENV / ENV, then production.
SUPERFLOWS_SERVICEService name; falls back to package.json / pyproject name, then the folder.
SUPERFLOWS_RELEASERelease version; the git SHA is detected from CI variables or .git.
SUPERFLOWS_DISABLED=1Turns the SDK into a no-op.
SUPERFLOWS_DEBUG=1Prints the SDK's own debug lines to stderr.

Guarantees

  • Nothing the SDK does can throw into your code; every hook is guarded.
  • Timers never keep your process alive; at most 1 MB is buffered, oldest dropped first.
  • Crashes and unhandled rejections behave exactly as without Superflows: same output, same exit code.
  • Measured overhead: about 1.3 µs of CPU per request and 5 MB of memory.