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
| Framework | Setup |
|---|---|
| Express 4 and 5 | Nothing else. |
| Next.js 15 (app router) | Call init from instrumentation.js when NEXT_RUNTIME === "nodejs". |
| Fastify, Koa | superflows.instrument(app) right after creating the app. |
| Plain http / https | Requests are counted; without a framework they appear as <unmatched>. |
API
| Call | What 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
| Variable | Meaning |
|---|---|
SUPERFLOWS_KEY | Ingest key (also read from .env). Required except against superflows dev. |
SUPERFLOWS_ENDPOINT | Defaults to https://ingest.superflows.cloud. Use http://localhost:4318 with superflows dev. |
SUPERFLOWS_ENV | Environment name; falls back to NODE_ENV / ENV, then production. |
SUPERFLOWS_SERVICE | Service name; falls back to package.json / pyproject name, then the folder. |
SUPERFLOWS_RELEASE | Release version; the git SHA is detected from CI variables or .git. |
SUPERFLOWS_DISABLED=1 | Turns the SDK into a no-op. |
SUPERFLOWS_DEBUG=1 | Prints 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.