rrweb-player
Overview
Use this package to get a feature-rich playback UI out of the box; if you want to build your own UI use the @rrweb/replay package.
This is the same replayer used in the cloud dashboard, if you want to try out a replay of your website, you can sign up and make a quick recording using the 'Test record any webpage' bookmarklet.
How is this different from new Replayer()?
new Replayer() is from the more foundational @rrweb/replay package, which renders and rebuilds an rrweb event stream within an iframe. This package builds on that to provide UI in the form of play/pause controls and a timeline using the Svelte UI framework. The similar naming is unfortunate, and we aim to fix that in a future major version.
Installation
1) Bundler / npm (Recommended)
npm install rrweb-playerimport rrwebPlayer from 'rrweb-player';
import 'rrweb-player/dist/style.css';2) Browser Without Bundler (ESM)
<link
rel="stylesheet"
href="https://cdn.rrweb.com/rrweb-player/current/style.css"
/>
<script type="module">
import rrwebPlayer from 'https://cdn.rrweb.com/rrweb-player/current/rrweb-player.js';
</script>Use current for the latest stable release, or pin an exact version such as https://cdn.rrweb.com/rrweb-player/2.0.0/rrweb-player.js for immutable production URLs. See the CDN assets docs for the full URL shape and catalog.
3) Legacy Direct <script> Include (UMD fallback)
Use this only for compatibility with non-module environments.
<link
rel="stylesheet"
href="https://cdn.rrweb.com/rrweb-player/current/style.css"
/>
<script src="https://cdn.rrweb.com/rrweb-player/current/rrweb-player.umd.cjs"></script>Usage
new rrwebPlayer({
target: document.body, // customizable root element
props: {
events,
},
});Options
| key | default | description |
|---|---|---|
| events | [] | the events for replaying |
| width | 1024 | the width of the replayer |
| height | 576 | the height of the replayer |
| maxScale | 1 | the maximum scale of the replayer (1 = 100%), set to 0 for unlimited |
| autoPlay | true | whether to autoplay |
| speed | 1 | The default speed to play at |
| speedOption | [1, 2, 4, 8] | speed options in UI |
| showController | true | whether to show the controller UI |
| tags | {} | customize the custom events style with a key-value map |
| inactiveColor | #D4D4D4 | Customize the color of inactive periods indicator in the progress bar with a valid CSS color string. |
| ... | - | all the rrweb Replayer options will be bypassed |
Methods on the rrwebPlayer component
addEventListener(event: string, handler: (params: any) => unknown): void;addEvent(event: eventWithTime): void;getMetaData() => {
startTime: number;
endTime: number;
totalTime: number;
}getReplayer() => Replayer;getMirror() => Mirror;Toggles between play/pause
toggle();Sets speed of player
setSpeed(speed: number)Turns on/off skip inactive
toggleSkipInactive();Triggers resize, do this whenever you change width/height
triggerResize();Plays replay
play();Pauses replay
pause();Go to a point in time and pause or play from then
goto(timeOffset: number, play?: boolean)Plays from a time to a time and (optionally) loop
playRange(
timeOffset: number,
endTimeOffset: number,
startLooping: boolean = false,
afterHook: undefined | (() => void) = undefined,
)Release Notes for rrweb-player
2.1.1
Patch Changes
#1901
a11f8efThanks @kevinvandijk! - Fix the rrweb-player production build so Svelte lifecycle APIs resolve to the browser runtime instead of to stubsUpdated dependencies []:
- @rrweb/replay@2.1.1
- @rrweb/packer@2.1.1
2.1.0
Patch Changes
- Updated dependencies [
7f0f75f]:- @rrweb/replay@2.1.0
- @rrweb/packer@2.1.0
2.0.1
Patch Changes
- Updated dependencies []:
- @rrweb/replay@2.0.1
- @rrweb/packer@2.0.1
2.0.0
Major Changes
#1497
2606a2aThanks @Juice10! - Distributed files have new filenames, paths and extensions. Important: If you reference distributed files or types directly, you might have to update your paths/filenames. E.g. you import fromrrweb/typings/...orrrdom/es. However you runimport rrweb from 'rrweb'you won't notice a difference with this change. If you include rrweb files directly in a script tag, you might have to update that path to include a the.umd.cjsfiles instead. All.jsfiles now use ES modules which can be used in modern browsers, node.js and bundlers that support ES modules. All npm packages now also ship.cjsand.umd.cjsfiles. The.umd.cjsfiles are CommonJS modules that bundle all files together to make it easy to ship one file to browser environments (similar to the previous.jsfiles). The.cjsfiles are CommonJS modules that can be used in older Node.js environments. Types should be better defined inpackage.jsonand if you need specific types they might be exported from new packages (for examplePlayerMachineStateandSpeedMachineStateare now exported from@rrweb/replay). Check thepackage.json'smainandexportsfield for the available files.#1031
ad9bc3eThanks @Juice10! - Move shared rrweb event and recorder types into the new@rrweb/typespackage.
Minor Changes
#1039
bdd8940Thanks @DexxDing! - Add inactive-period indicators to the player progress bar with a configurableinactiveColoroption.#1007
3924aafThanks @Juice10! - Addplayer.playRange(start, end, loop?, afterHook?)to play a bounded time range, optionally looping or invoking a callback when the range ends.#1006
6f63cf1Thanks @Juice10! - Add amaxScaleoption to configure the player's maximum replay scale, with0allowing unlimited scaling.#859
e238462Thanks @Juice10! - Add support for recording canvas snapshots at a configured FPS.#895
de755aeThanks @Juice10! - Add the fast-forward virtual DOM optimization for replay.
Patch Changes
#1198
b5e30cfThanks @charliegracie! - Reset the finished flag in Controllergotoinstead ofhandleProgressClickso that it is properly handled ifgotois called directly.#1287
efdc167Thanks @Juice10! - Upgrade all projects to typescript 4.9.5#1126
227d43aThanks @YunFeng0817! - Refactor all suffix of bundled scripts with commonjs module from 'js' to cjs #1087.#1247
a01a12eThanks @Juice10! - Fixplayer.getMirror,player.playRange,player.$settypes in rrwebPlayer#1704
33e01f5Thanks @eoghanmurray! - Provide a /umd/ output folder alongside the /dist/ one so that we can serve UMD (Universal Module Definition) files with a .js extension, without upsetting expectations set by package.json that all .js files in /dist/ are modules#1028
2286c11Thanks @MengZihan712! - Fix fullscreen player sizing so the progress bar and controls remain visible.#1014
9de0de2Thanks @Juice10! - Add the missingmaxScaleoption to rrweb-player TypeScript definitions and document player option defaults.#1045
e08d039Thanks @YunFeng0817! - Fix rrweb-player TypeScript imports after the@rrweb/typessplit.Updated dependencies [
b2d5689,a8478f1,ce6019d,bac1d7b,5ba933c,fd85c79]:- rrweb@2.0.0-alpha.2
Updated dependencies [
f1b23dd]:- rrweb@2.0.0-alpha.1
Updated dependencies [
22bc4c3,db20184,22bc4c3,2606a2a,2606a2a,2606a2a,33e01f5]:- @rrweb/replay@2.0.0
- @rrweb/packer@2.0.0
2.0.0-alpha.16—20
Patch Changes only following changes to @rrweb/replay and @rrweb/packer
Patch Changes
- Updated dependencies [
db20184]:- @rrweb/replay (2.0.0-alpha.16—20)
- @rrweb/packer (2.0.0-alpha.16—20)
2.0.0-alpha.15
Major Changes
- #1497
2606a2aThanks @Juice10! - Distributed files have new filenames, paths and extensions. Important: If you reference distributed files or types directly, you might have to update your paths/filenames. E.g. you import fromrrweb/typings/...orrrdom/es. However you runimport rrweb from 'rrweb'you won't notice a difference with this change. If you include rrweb files directly in a script tag, you might have to update that path to include a the.umd.cjsfiles instead. All.jsfiles now use ES modules which can be used in modern browsers, node.js and bundlers that support ES modules. All npm packages now also ship.cjsand.umd.cjsfiles. The.umd.cjsfiles are CommonJS modules that bundle all files together to make it easy to ship one file to browser environments (similar to the previous.jsfiles). The.cjsfiles are CommonJS modules that can be used in older Node.js environments. Types should be better defined inpackage.jsonand if you need specific types they might be exported from new packages (for examplePlayerMachineStateandSpeedMachineStateare now exported from@rrweb/replay). Check thepackage.json'smainandexportsfield for the available files.
Patch Changes
- Updated dependencies [
2606a2a,2606a2a,2606a2a]:- @rrweb/packer@2.0.0-alpha.15
- @rrweb/replay@2.0.0-alpha.15
2.0.0-alpha.12—14
Patch Changes only following changes to rrweb
Patch Changes
- Updated dependencies [
03b5216,ae6908d,46f1b25,cbbd1e5,e96f668,3d1877c,123a81e,02f50d2,af0962c,57a940a,8aea5b0,9c6edfe,1e0b273,1fe39ab,05478c3,58c9104,980a38c,a2be77b,a7c33f2,314a8dd,7c0dc9d,07ac5c9]:- rrweb (2.0.0-alpha.12—14)
2.0.0-alpha.11
Patch Changes
#1287
efdc167Thanks @Juice10! - Upgrade all projects to typescript 4.9.5Updated dependencies [
11f6567,efdc167]:- rrweb@2.0.0-alpha.11
2.0.0-alpha.10
Patch Changes
2.0.0-alpha.9
Patch Changes
#1247
a01a12eThanks @Juice10! - Fixplayer.getMirror,player.playRange,player.$settypes in rrwebPlayerUpdated dependencies [
490b3e2,a1ec9a2,490b3e2,d7c72bf,ebcbe8b]:- rrweb@2.0.0-alpha.9
2.0.0-alpha.8
Patch Changes
#1198
b5e30cfThanks @charliegracie! - Reset the finished flag in Controllergotoinstead ofhandleProgressClickso that it is properly handled ifgotois called directly.Updated dependencies [
b5e30cf,979d2b1,bc84246,aa79db7]:- rrweb@2.0.0-alpha.8
2.0.0-alpha.7
Patch Changes
- Updated dependencies [
e0f862b,267e990,d2582e9,a225d8e,a82a3b4,1e6f71b,1e6f71b,4cb4d0e]:- rrweb@2.0.0-alpha.7
2.0.0-alpha.6
Patch Changes
- Updated dependencies [
e65465e,f27e545,f6f07e9,3416c3a,8e47ca1,aaabdbd,5e6c132]:- rrweb@2.0.0-alpha.6