Docs / Node

Install the Node.js SDK

At the end your app sends events and errors to Vinktar on one key, and identify() joins them to a person.

Before you start

@vinktarhq/node (npm). JavaScript and TypeScript on Node.js 18.17 and later, Bun, Deno, Cloudflare Workers and Vercel Edge.

You need a Vinktar project. Replace vnk_pk_YOUR_KEY below with its public write key. The app shows the same snippets with your key filled in.

A coding agent connected over MCP can do this install for you. It reads the install guide, fetches the key, wires identify, defines the events it adds and checks what arrived. Connect your agent.

1. Install

npm install @vinktarhq/node

2. Initialise

import { init, track } from '@vinktarhq/node';
import { vinktarRequest, vinktarErrors } from '@vinktarhq/node/express';

init({
  writeKey: process.env.VINKTAR_KEY,
  release: process.env.GIT_SHA,
  captureErrors: true,         // uncaught exceptions and fatal rejections
});

app.use(vinktarRequest());     // a scope per request
app.post('/orders', (req, res) => {
  track('Order completed', { amount: 4900 }, { userId: req.user.id });
  res.json({ ok: true });
});
app.use(vinktarErrors());

// Fastify: @vinktarhq/node/fastify · NestJS: @vinktarhq/node/nest · Workers, Vercel Edge: @vinktarhq/node/edge

Check it worked

Run the process. Events go out every 10 s or at 20 queued; a script calls await close() before it exits.

Join events and errors to a person

Anonymous activity is kept under the device. The first identify() with a user id binds that device to the person, and everything before it resolves to them retroactively. A device binds once; call reset() on logout so the next person gets a fresh one. The full rules are in api.md.

Next