The npm package
@parlox/browser for sites with a build step: React, Next.js, Vue and any bundler.
On this page
@parlox/browser is the browser part for sites with a build step. It is bundled into your own code, pinned by your lockfile, and fetches nothing from Parlox at runtime except the answers to its beacons. The source is public: github.com/parlox-io/parlox-js (MIT).
Install
npm install @parlox/browserTo pin the exact release, as the install wizard does:
npm install --save-exact @parlox/browser@1.0.3React and Next.js
Render the component once, in the root layout. It renders nothing and starts Parlox once, after hydration, in the browser. The built file carries "use client", so it can sit in a server layout.
import { ParloxAnalytics } from "@parlox/browser/react";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<ParloxAnalytics publicKey="pk_…" />
</body>
</html>
);
}On the Pages Router, put it in pages/_app.tsx. On Vite React, render it once beside <App /> in the entry file your index.html names (usually src/main.tsx, inside <StrictMode> when the app uses it).
Vue
Call init once in the entry file your index.html loads (usually src/main.ts), before the app mounts. Nothing else is needed for Vue Router:
import { createApp } from "vue";
import { init } from "@parlox/browser";
import App from "./App.vue";
import router from "./router";
init({ publicKey: "pk_…" });
createApp(App).use(router).mount("#app");- Vite with
@vitejs/plugin-legacy: nothing extra. The recorder is a separate chunk in both the modern build and the legacy (SystemJS) build, and loads in both. - Served by nginx or any static host: nothing extra for the browser part. The recorder chunk is a file in your build's
assets/, served like the rest of the build. - Your GA4 data layer (
gtagordataLayer.pushwithecommerce) is read automatically: Cart and checkout events.
Checked on 2026-10-16 with Vue 3.5, Vue Router in history mode, Vite 8 and @vitejs/plugin-legacy 8, served the way nginx serves a single-page app, in Chromium, Firefox and WebKit: a page view for each route, the data layer's add_to_cart read, and the recorder loaded, in both the modern and the legacy build.
The install wizard does not cover Vue yet, so this is the route by hand.
Any other bundler
The same call, once, as early as possible in code that runs in the browser:
import { init } from "@parlox/browser";
init({ publicKey: "pk_…" });init is safe to import during server-side rendering: there it does nothing and returns null. In a framework that renders on the server, make sure the call also runs in the browser. A second call returns the running instance; it never starts Parlox twice.
Single-page apps
Route changes need no setup. The tracker wraps history.pushState and history.replaceState and listens to popstate, so each route change in history mode (Vue Router's createWebHistory(), React Router's browser router) closes the current page and starts the next one, as a full page load would.
Options
init({
publicKey: "pk_…", // required: the site's public key
consent: "required", // keep Parlox off until consent(true); default "granted"
recordAgents: false, // never record agent visits; default true
});The component takes the same options as props. Every option, and track, consent and sessionId: Browser API.
What goes into your bundle
- The tracker, in your main bundle.
- The recorder, as a separate chunk your bundler builds from a lazy
import(). It is downloaded only when the page's own signals say the browser is automated, so a person's browser does not load it, with one edge case: a person on a virtual machine or a remote desktop can be judged automated, and their visit is then recorded, masked like an agent's; a browser with graphics acceleration turned off may be too (inferred, not tested) (Agent recordings). WithrecordAgents: falseit is never loaded.
The package has one runtime dependency, @rrweb/record, used by the recorder; it brings in rrweb, @rrweb/types and @rrweb/utils.
Where it sends
Only to https://gateway.parlox.io: beacons to /v1/b and recording chunks to /v1/r. With a Content-Security-Policy, allow it in connect-src (Content-Security-Policy).
The gateway stores beacons only from pages on the site's own domain, its www form and its subdomains. A page on localhost or on a preview address under another domain sends nothing that is kept.
Ownership
An npm install puts no tag in your HTML, so it does not prove you own the domain by itself. Set PARLOX_VERIFY_TOKEN for the server part to answer, or add the DNS record: Verifying the domain.