Docs / Browser

Install the browser 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/browser (npm). JavaScript and TypeScript in the browser. Every browser released since 2020.

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/browser

2. Initialise

import { init, identify, track, reset } from '@vinktarhq/browser';

init({
  writeKey: 'vnk_pk_YOUR_KEY',
  release: 'web@1.0.0',        // ties issues to deploys
  autocapture: true,           // clicks and form submits, on top of pageviews
});

// After sign-in, so errors and events join to a person:
identify('user_123', { email: 'dana@example.com', plan: 'pro' });
track('Signed up');

// On logout, so the next person on this browser is not attributed to the last:
reset();

Check it worked

Reload the page. The first pageview appears in Events within a few seconds, and the person on People. It imports safely during server rendering and does nothing until it has a window.

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