The one-line answer
Install @relyv/sdk via npm, call init({ apiKey, projectId }) once at app entry, and the SDK records every session from first render — including network calls, console errors, and DOM mutations — with ~14 KB gzipped and sub-1% main-thread overhead.
What you need before starting
Three prerequisites:
- <strong>A Relyv account</strong> (free tier covers 1,000 sessions/mo).
- <strong>API key + project ID</strong> from dashboard.relyv.ai → Settings → API keys.
- <strong>Edit access to your React app entry file</strong> (main.tsx, index.tsx, or equivalent).
How Relyv React setup works
The SDK is framework-agnostic but behaves correctly inside React out of the box. It hooks the History API for route-change detection (works with React Router, TanStack Router, Wouter), captures the initial DOM after first paint, and subscribes to MutationObserver for every subsequent change. StrictMode's double-render doesn't cause duplicate sessions — the SDK deduplicates on session ID, not init calls.
Step-by-step
- 1
Install the SDK
Run
npm install @relyv/sdk(orpnpm add @relyv/sdk/yarn add @relyv/sdk/bun add @relyv/sdk). The package is fully typed; types are exported alongside the runtime. - 2
Initialise at app entry
Add one import + one init call to your top-level entry file:
// main.tsx (Vite) or index.tsx (CRA) import { init } from '@relyv/sdk'; init({ apiKey: import.meta.env.VITE_RELYV_API_KEY, projectId: import.meta.env.VITE_RELYV_PROJECT_ID, }); // rest of your render code ReactDOM.createRoot(...).render(...);
Init must run on the client (in the browser), not at build time. Vite + CRA satisfy this automatically because main.tsx runs in the browser. - 3
Mark sensitive fields
Add the
data-relyv-maskattribute to any element rendering PII the SDK can't identify by content alone:<input data-relyv-mask name="customer-id" /> <div data-relyv-mask>{user.fullName}</div>
Standard PII (emails, phone numbers, credit cards) is masked automatically via regex + Luhn validation — no marker needed. - 4
Verify in dev before deploying
Run your app locally, click around for 30 seconds, then open the Relyv Library at dashboard.relyv.ai. The session appears within seconds. Watch the replay end-to-end, open the Network and Console tabs inside the replay viewer, and confirm no PII leaks. Check the "raw payload" tool in Settings if you want to see the exact serialized capture.
- 5
Deploy + monitor
Push to staging, watch the session corpus grow, look for the first AI-summarised bug ticket in the Triage inbox within a few hours. Production deploy follows the same pattern; no per-environment configuration beyond the API key/project ID for the corresponding workspace.