Docs Set up your stack

Set up Relia in a Firebase app

Watch a Firebase app: the web app with Firebase errors named in plain words, and your Cloud Functions with their Firestore calls.

This page sets up a Firebase app in two parts: the web app and Cloud Functions. Do the ones your app has. 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, and your app's repository with its web app folder and its functions/ folder.

Steps

Part 1: the web app

  1. In your web app's folder, run:

    npx relia-sdk@latest init
    
  2. Sign in, choose Everything Relia found here, pick your project and answer the two questions. The full walkthrough is in Watch your web app.

With the Firebase JS SDK, Relia then names Firebase's errors in plain words:

  • permission-denied: blocked by your security rules. When your rules refuse users, the incident says so and tells you to check your Firestore and Storage security rules.
  • resource-exhausted: a quota or rate limit was hit.
  • unavailable, unauthenticated, failed-precondition (often a missing index), and Auth codes like invalid-credential.

Sign-ins and sign-ups are counted by outcome. Firestore reads and writes made from the browser travel over a streaming connection that can't be timed one by one, so for those Relia shows the errors, not each query's speed.

Tip: watch Fix JavaScript errors in production with readable stack traces (2 min).

Part 2: Cloud Functions (Node)

  1. Run the same command in your functions/ folder:

    cd functions
    npx relia-sdk@latest init
    
  2. It finds Firebase Cloud Functions by itself. Choose Everything Relia found here and pick the same project.

  3. Check what it wrote: a new relia.tracing.js, loaded as the first line of index.js (or src/index.ts), before firebase-functions and firebase-admin.

To do it by hand instead: run npm install relia-sdk in functions/, create functions/relia.tracing.js:

require("relia-sdk/node").start({
  serviceName: "shop-functions",
  projectId: "<your project id>",
  key: "<your project key>",
})

and make it the first line of functions/index.js:

require("./relia.tracing")   // TypeScript: import "./relia.tracing" first in src/index.ts

Relia notices it runs as a Cloud Function and switches to serverless mode by itself:

  • each function call becomes a request named after the function;
  • a function that throws is recorded as a failed request with its error. It is answered 500, and Firebase still sees the crash as before;
  • Firestore calls made with the Admin SDK become database calls;
  • the data is sent before each response, because Google stops the function's CPU right after it answers. That adds roughly 50 to 200 ms per call, never more than 1 second. If your functions use CPU always allocated, set RELIA_FLUSH=after to skip the wait.

Cloud Functions in Python instead

Add relia-sdk[otel,flask] to functions/requirements.txt, then at the top of main.py:

import relia
relia.start(project_id="<your project id>", service_name="shop-functions")

Put RELIA_KEY=<your project key> in functions/.env. The same serverless mode applies.

Test with the emulator

The emulator sends data too, so you can check before deploying. Put RELIA_ENV=development in functions/.env.local so test traffic stays apart from production. Restart a running emulator after adding Relia. The emulator loads a function's code during its first call, so that one call isn't recorded; deployed functions load first.

When you're ready, deploy as usual with firebase deploy --only functions.

Check it worked

Open your web app once and call a function. On your project's Setup tab, Visits to your web app and Requests from your server change from Not yet to Arriving. Your function calls appear under APIs, and their Firestore calls under Database.

If something's wrong

  • The first call in the emulator is missing: that's expected; call the function again.
  • Function calls don't arrive after editing: restart the emulator. Running workers keep the old code.
  • Relia isn't loaded: require("./relia.tracing") must come before firebase-functions and firebase-admin.
  • Still "Not yet": see Relia shows no data.

Next

Last checked against the product: 1 Nov 2026