Skip to Content

Treblle Docs

The official Treblle SDK for JavaScript frameworks including node. Seamlessly integrate Treblle to manage communication with your dashboard, send errors, and secure sensitive data.

Treblle with Node.js

Requirements

  • Node.js: >=14.0.0 (14.x LTS or higher recommended)

Installation

npm install treblle@^2.0.0

Setting up credentials

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

Choose Your Framework

The Treblle SDK works with popular Node.js frameworks:

Full Express integration guide →

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

Fastify (High Performance)

Full Fastify integration guide →

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

Koa (Minimalist)

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: "..." });

Strapi (Headless CMS)

Full Strapi integration guide →

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

Next.js (React Framework)

Full Next.js integration guide →

import { withTreblle } from "@treblle/next/integrations/nextjs"; export const GET = withTreblle(async () => NextResponse.json({}));

Other Frameworks

  • AdonisJS - Recommended using unified SDK
  • SailsJS - Recommended using unified SDK with Koa
  • Directus - Headless CMS integration

Core Configuration

All frameworks use the same unified configuration:

Option

Type and Description

sdkToken

string (required) - Your SDK Token

apiKey

string (required) - Your API Key

additionalFieldsToMask

array (optional) - Extra fields to mask - Example: ['apiKey', 'internalId']

blocklistPaths

array (optional) - Paths to exclude - Example: ['admin', 'health']

ignoreDefaultBlockedPaths

boolean (optional) - Disable defaults - Default: false

debug

boolean (optional) - Show errors - Default: false

Automatic Field Masking

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"]

Default Blocked Paths

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

Production Setup

Run Treblle only in production:

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

Tip

For production environments, consider using environment-based configuration to automatically enable Treblle without code changes.

Debugging

Enable debug mode:

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

Note

Debug mode should only be enabled in development environments as it may expose sensitive configuration details in logs.

Last updated on