SDKs

Node.js SDK

Install the Logdash Node.js SDK, send your first log and your first metric.

Install the package, add your ingest key and the first log lands in the dashboard within a second. Everything below is copied from the Node.js SDK README.

Install

npm install @logdash/node

Initialise

Copy the ingest key from your domain's settings in Logdash and keep it in an environment variable. The key identifies the domain the data lands in, and app names the program that sends, such as api or worker. See Apps.

import { Logdash } from '@logdash/node';

const logdash = new Logdash(process.env.LOGDASH_API_KEY, { app: 'api' });

Send a log

import { Logdash } from '@logdash/node';

const logdash = new Logdash(process.env.LOGDASH_API_KEY);

logdash.info('Application started successfully');
logdash.error('An unexpected error occurred');
logdash.warn('Low disk space warning');

Send a metric

Metrics are named numbers. Set one to an absolute value or mutate it by a delta, and Logdash charts the history.

import { Logdash } from '@logdash/node';

const logdash = new Logdash(process.env.LOGDASH_API_KEY);

// to set absolute value
logdash.setMetric('users', 0);

// to modify existing metric
logdash.mutateMetric('users', 1);

Send an event

Events go to web analytics of the domain, next to the custom events of your website, with the same rules for names and properties.

import { Logdash } from '@logdash/node';

const logdash = new Logdash(process.env.LOGDASH_API_KEY);

logdash.track('agent_run', { model: 'opus', tools: 3 }, { userId: user.id });

Flush before exit

The SDK sends in the background. In a short-lived process, such as a cron job, a CLI or a serverless function, send what is still queued before the process exits.

// Ensure all logs, metrics and events are sent before exiting
await logdash.flush();

Works with

  • Express
  • NestJS
  • Fastify
  • Next.js
  • SvelteKit
  • Bun

FAQ

Does it work with TypeScript?
Yes. Every example in the README is TypeScript and Logdash is a named export. The same package runs on Node, Bun and Deno.
How do I stop losing logs when the process exits?
Await logdash.flush() before you exit. It sends everything still queued, which matters in short-lived processes like cron jobs and serverless handlers.
Can I point it at a self-hosted instance?
Yes. Pass options.host to the constructor. It defaults to https://api.logdash.io.

Copied from the node-sdk README at 0ff4b8c on 2026-11-09.