Skip to content

Nuxt

  1. Install the package.

    Terminal window
    npm install @ritim/browser-sdk
  2. Add a client plugin. The .client suffix is the important part: it tells Nuxt to run this on the browser only, and init() touches window.

    plugins/ritim.client.ts
    import { init } from '@ritim/browser-sdk';
    export default defineNuxtPlugin(() => {
    init({ projectKey: 'P-ABC123' });
    });

That is the entire integration — Nuxt auto-registers anything in plugins/, so there is nothing to add to nuxt.config.ts.

You do not hook useRouter or router.afterEach either. Vue Router navigates by calling history.pushState, which the SDK already watches.

Nuxt is the easy case. It publishes a build identifier on every client payload — app.buildId in the runtime config — and the SDK reads it. A Nuxt app that configures nothing still gets one release per deploy, on both install paths, and the dashboard can attribute a regression to a specific build.

The catch is what that value is. Nuxt generates it per build, so it is stable across a deploy and changes when you rebuild — the right shape for a release — but it is a generated identifier rather than one you chose. It tells you which build regressed without telling you what changed in it.

Set buildId in nuxt.config.ts. It is the same field the SDK already reads, so there is nothing to change in your plugin or your script tag:

nuxt.config.ts
export default defineNuxtConfig({
buildId: process.env.GIT_SHA,
});

Now the release is a commit you can look up, and detection keeps working exactly as before. See buildId in the Nuxt config reference.

Nuxt’s runtime config is readable on the client and overridable by an environment variable at run time, which is what makes it the right home for a value that differs per environment:

nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
public: {
buildId: '',
},
},
});
plugins/ritim.client.ts
import { init } from '@ritim/browser-sdk';
export default defineNuxtPlugin(() => {
const { public: config } = useRuntimeConfig();
init({
projectKey: 'P-ABC123',
release: config.buildId || undefined,
});
});

Because it is runtime config, NUXT_PUBLIC_BUILD_ID overrides it wherever the app runs, with no rebuild. The naming rule and the full mechanism are in Runtime Config.