Skip to content

Treblle with Node.js

Treblle provides a unified SDK for Node.js that works with all major frameworks. This page covers the core Node.js integration and points to framework-specific guides.

  • Node.js: >=14.0.0 (14.x LTS or higher recommended)
Terminal window
npm install treblle@^2.0.0

Create a free account on treblle.com to get your credentials:

  • sdkToken (SDK Token)
  • apiKey (API Key)

Add these to your .env file:

TREBLLE_SDK_TOKEN=your_sdk_token
TREBLLE_API_KEY=your_api_key

The Treblle SDK works with popular Node.js frameworks:

Full Express integration guide →

const { useTreblle } = require("treblle");
useTreblle(app, { sdkToken: "...", apiKey: "..." });

Full Fastify integration guide →

const { fastifyTreblle } = require("treblle");
await fastify.register(fastifyTreblle, { sdkToken: "...", apiKey: "..." });

Full Koa integration guide →

const { koaTreblle } = require("treblle");
app.use(koaTreblle({ sdkToken: "...", apiKey: "..." }));

Full NestJS integration guide →

const { useNestTreblle } = require("treblle");
useNestTreblle(expressInstance, { sdkToken: "...", apiKey: "..." });

Full Strapi integration guide →

const { strapiTreblle } = require("treblle");
strapiTreblle({ sdkToken: "...", apiKey: "..." });

Full Next.js integration guide →

import { withTreblle } from "@treblle/next/integrations/nextjs";
export const GET = withTreblle(async () => NextResponse.json({}));
  • AdonisJS - Recommended using unified SDK
  • SailsJS - Recommended using unified SDK with Koa
  • Directus - Headless CMS integration

All frameworks use the same unified configuration:

{
sdkToken: "required", // Your SDK Token
apiKey: "required", // Your API Key
additionalFieldsToMask: [], // Optional: Extra fields to mask
blocklistPaths: [], // Optional: Paths to exclude
ignoreDefaultBlockedPaths: false, // Optional: Disable defaults
debug: false // Optional: Show errors
}

The following fields are automatically masked:

  • password, pwd, secret, password_confirmation, passwordConfirmation
  • cc, card_number, cardNumber, ccv
  • ssn
  • credit_score, creditScore

Add custom fields:

additionalFieldsToMask: ["apiKey", "internalId", "sessionToken"]

These paths are automatically skipped:

  • Files: favicon.ico, robots.txt, sitemap.xml, manifest.json, sw.js
  • Directories: /.well-known/, /static/, /assets/, /public/, /images/
  • Extensions: .css, .js, .png, .jpg, .gif, .svg, .ico, .woff, .ttf

Disable defaults:

ignoreDefaultBlockedPaths: true

Run Treblle only in production:

if (process.env.NODE_ENV === "production") {
// Initialize Treblle
}

Enable debug mode:

{
sdkToken: "...",
apiKey: "...",
debug: true // Show errors in console
}