Docs Set up your stack
Set up Relia in a Node.js or Express app
One command adds Relia to a Node.js server (Express, Fastify, NestJS, Koa, Hapi, Hono) so its requests, errors and database calls show up in Relia.
This page sets Relia up by hand from a terminal. To have your AI assistant do it instead, see Set up Relia with your AI assistant.
Before you start
- A Relia account (Create your account).
- A terminal open in your server's folder (the one with its
package.json).
Steps
Run the setup:
npx relia-sdk@latest initAlways use
relia-sdk: the npm package calledreliabelongs to someone else.Sign in. Choose the browser option, copy the token from the CLI Authentication page, and paste it back into the terminal.
Choose what to set up. The setup finds your server framework (for example Express API). Choose Everything Relia found here.
Pick your Relia project, or create one right there.
Answer "Tell Relia who your users are?" Say yes if your app has sign-in. The setup then prints the lines to add; see Identify your users.
Tip: watch See which customers a bug hit: identify users in Relia (2 min).
Check what it wrote:
- A new
relia.tracing.jswith your project's id and key. - One line at the top of your entry file (the file
npm startruns) that loads it first, for examplerequire('./relia.tracing');(the path depends on where your entry file is). - For Express: Relia's middleware after
const app = express(), and its error handler after your routes. relia-sdkadded to yourpackage.json.
- A new
Restart your app and call one of its endpoints. The console says
tracing initialized.
Set it up by hand instead
If you'd rather write the code yourself, install the package:
npm install relia-sdk
Create relia.tracing.js (your project's id and key are on your project page under Setup Guide & SDK):
require("relia-sdk/node").start({
serviceName: "my-api",
projectId: "<your project id>",
key: "<your project key>",
})
Load it as the very first line of your entry file, before any other import:
require("./relia.tracing") // ESM: import "./relia.tracing.js"
For Express, add the middleware and the error handler:
const relia = require("relia-sdk/node")
app.use(relia.expressMiddleware())
// ... your routes ...
app.use(relia.expressErrorHandler()) // after your routes: records errors with their stack trace
What Relia records
- Every request with its route, status and time: Express, Fastify, NestJS, Koa and Hapi.
- Errors with their stack traces.
- Outgoing HTTP and
fetchcalls. - Database calls (PostgreSQL, MongoDB, MySQL, Redis), with values removed.
- Queue jobs (BullMQ, SQS, Kafka) and GraphQL.
- Warnings and errors from
console.warn,console.error, winston and bunyan, as log lines. SetRELIA_LOGS=0to turn this off. - Calls to AI models in your product. See Monitor AI calls in your app.
Running several services in one project? Give each its own serviceName. Relia draws how they call each other on the Map.
When you deploy
Your project's id and key are inside relia.tracing.js, so your host needs no extra environment variable. Just deploy as usual.
Check it worked
Open your project in Relia and go to the Setup tab. Requests from your server changes from Not yet to Arriving, usually within a minute. Your requests and errors appear under APIs, and your queries under Database.
If something's wrong
- Still "Not yet" after a few minutes: make sure
relia.tracingis loaded before anything else in your entry file, restart the app and call an endpoint again. Then see Relia shows no data. - Errors show without a stack trace (Express):
expressErrorHandler()must come after your routes. - The setup refused to create a project: it shows the reason and offers your existing projects. Pick one of them.
Next
Last checked against the product: 1 Nov 2026