new Rive()
instance from the @rive-app/*
packages, or the <RiveComponent />
from the @rive-app/react-*
packages, your browser is making a network request to https://unpkg.com/@rive-app/canvas@x.x.x/rive.wasm
which retrieves a Web Assembly (WASM) file that contains Rive-specific APIs to build the render loop. unkpg is a global CDN that quickly allows for loading in NPM packages, which in this case includes a WASM file. This allows for a smaller bundle size when pulling in the Rive JS-based runtimes, while only loading in WASM when Rive instances are created.
While unpkg
should provide WASM quickly and can cache across sites that load from this CDN, you may want to preload and host the WASM file yourself for any of the following reasons:
@rive-app/canvas
or @rive-app/webgl
or any of the plain JS-variant Rive runtimes, import the WASM resource into your app, as well as the RuntimeLoader
API:
RuntimeLoader
is a singleton that manages loading in the WASM file behind the scenes when loading in the Rive
instance. By calling the setWasmUrl
API, you can load in WASM for the Rive runtime with the data URI from the direct import of the WASM file. Run this API on any page that has a Rive animation to load.
@rive-app/react-canvas
or @rive-app/react-webgl
, import the WASM resource into your app, as well as the RuntimeLoader
API:
RuntimeLoader
is a singleton that manages loading in the WASM file behind the scenes when loading in the Rive
instance. By calling the setWasmUrl
API, you can load in WASM for the Rive runtime with the data URI from the direct import of the WASM file. Run this API on any page that has a Rive animation to load.
@rive-app/canvas
at the version tied down with the correlated React version on @rive-app/react-canvas
or you may notice issues at runtime. For example, @rive-app/react-canvas@3.0.33
ties down the JS dependency at @rive-app/canvas@1.0.95
; therefore you may want to install that specific version of the JS runtime to ensure compatibility.