Nuxt
-
Install the package.
Terminal window npm install @ritim/browser-sdk -
Add a client plugin. The
.clientsuffix is the important part: it tells Nuxt to run this on the browser only, andinit()toucheswindow.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.
Declare it in nuxt.config.ts and Nuxt puts it in the head of every page:
export default defineNuxtConfig({ app: { head: { script: [ { src: 'https://cdn.ritim.io/latest/rum.min.js', async: true, 'data-project-key': 'P-ABC123', }, ], }, },});Or from a single page or layout, when you only want it on part of the site:
<script setup lang="ts">useHead({ script: [ { src: 'https://cdn.ritim.io/latest/rum.min.js', async: true, 'data-project-key': 'P-ABC123', }, ],});</script>Navigation still needs no wiring — Vue Router calls history.pushState, which
the SDK watches on its own.
Releases
Section titled “Releases”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.
Name it yourself
Section titled “Name it yourself”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:
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.
Or declare it at runtime
Section titled “Or declare it at runtime”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:
export default defineNuxtConfig({ runtimeConfig: { public: { buildId: '', }, },});import { init } from '@ritim/browser-sdk';
export default defineNuxtPlugin(() => { const { public: config } = useRuntimeConfig();
init({ projectKey: 'P-ABC123', release: config.buildId || undefined, });});export default defineNuxtConfig({ app: { head: { script: [ { src: 'https://cdn.ritim.io/latest/rum.min.js', async: true, 'data-project-key': 'P-ABC123', 'data-release': process.env.GIT_SHA, }, ], }, },});The head is rendered at build time here, so this is the build-time route rather
than the runtime one — prefer buildId above unless you have a reason not to.
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.