Install
Initialize
1
Start recording
Call the initializer as early as possible — recording begins immediately. Only
apiKey and apiHost are required.init() is idempotent — a second call returns the live session instead of starting a second recording.Why the loader looks like this. Loading the bundle with
async means it
never blocks your page from rendering, and the small inline stub queues any
init/track calls made before the bundle finishes downloading (they replay
in order once it does). The crossorigin="anonymous" attribute is what lets
the browser hand Replayfy a full error stack trace instead of a bare
"Script error." — without it, the browser’s cross-origin security model
strips the message, file, and stack from any error thrown by a script served
from another origin (the CDN). Replayfy’s CDN sends the matching
Access-Control-Allow-Origin header, so the two work together. If you self-host
the bundle on a host that does not send that header, drop the crossorigin
line — otherwise the browser will refuse to load the script.2
Identify the user (optional)
Attach a distinct id and traits so replays and events are tied to a real person.Include
picture (or its alias avatar) with a public https image URL — either top-level or inside customProps — to set the user’s avatar in the recording header and Users list; non-URL values are ignored. With the script tag you call these on the Replayfy global (no returned controller to hold).React / Next.js — call
initReplay(...) once in a top-level client effect (e.g. a root useEffect or a "use client" provider) so it runs in the browser, not during server rendering. The single instance persists across route changes.Verify
Reload your app, click around for a few seconds, then open the Sessions view in your Replayfy dashboard — your first session appears within a minute.
Configuration
Pass these options toinitReplay(config) (npm) or Replayfy.init(config) (CDN). Only apiKey and apiHost are required.
Privacy, capture, and sampling settings configured in your Replayfy dashboard are fetched at startup and take precedence over the values passed to
init() — so you can tighten masking or pause recording without shipping a new build.Auto-captured clicks are now labelled with the element’s real text — its
aria-label, title, associated form-control label, or trimmed visible caption — instead of a raw CSS selector, so heatmaps and click funnels read as human-friendly names (an input’s typed value is never used as a label).API reference
initReplay() returns a controller with the methods below. With the CDN global, the same methods are available as Replayfy.identify(...), Replayfy.track(...), etc., after Replayfy.init(...).
Privacy & masking
Replayfy is designed to keep sensitive data in the browser — every<input> value is masked by default. Tune redaction with these options:
maskAllInputs(defaulttrue) — masks the value of every input field in the replay.maskTextSelector— CSS selector for text nodes to mask (e.g..pii, .account-number), shown as●●●●in playback.blockSelector— CSS selector for elements to block entirely; they render as a placeholder box.redactUrls— string/RegExppatterns stripped from captured URLs, so tokens and ids never leave the page.excludeUrls— path globs for whole pages that must never be recorded (e.g.["/settings/billing", "/admin/**"]); a matching page captures and ships nothing at all.captureHeaders(defaultfalse) — headers are only captured when explicitly enabled.redactHeaderNames— additional header names whose values are masked, on top of the always-on built-in deny-list.maxBodyBytes— caps how much of a request/response body is ever captured.
For full control,
beforeSend receives each batch before it leaves the browser, so you can drop or scrub anything programmatically.Identify users
Tie sessions and events to real people with distinct ids and traits.
Track events
Fire custom product events to power funnels, segments, and retention.
Privacy & masking
Redact inputs, text, elements, and URLs before data leaves the browser.