@rive-app/canvas
(more on that below). On the web, Rive offers the ability to use a backing CanvasRenderingContext2D
context or WebGL
context associated with a <canvas>
element for rendering Rive animations.
Note: The high-level API and the logic for creating a Rive instance in your script remain the same for the @rive-app/webgl
and @rive-app/canvas
packages. That means if you decide one runtime package is better for your use case over the other, you only need to switch the dependency, but not the usage. See more below on each of the different runtimes for JS/WASM and when to use which package.
@rive-app/canvas-lite
below 👇@rive-app/canvas
with the same API and backing CanvasRenderingContext2D, but does not compile and build WASM with certain dependencies in order to keep the package size as small as possible.
This solution will be preferable if you do not have a need for the following features below:
new Rive({...})
instances created.
If you’re planning on displaying Rive content in a list/grid or many times on the same page, it’s up to you to manage the lifecycle of the provided context and canvas
element. If you need to display many animations (i.e grids/lists), consider using the @rive-app/canvas
package which uses the CanvasRenderingContext2D
renderer and does not have a context limitation, or consider the @rive-app/webgl-advanced
package, which will allow you to display multiple Rive graphics on one canvas with full control over the render loop.
useOffscreenRenderer: true
property in the Rive parameters when creating a new Rive({...})
object, especially when rendering multiple Rive objects on the page.@rive-app/webgl
will make use of the Rive Renderer completely, without an added Skia dependency@rive-app/webgl
, which currently adds a larger Skia dependencyWEBGL_shader_pixel_local_storage
Chrome Extension (by adding WebGL Draft Extensions in the link above), otherwise, Rive will fall back to an MSAA solution (also with WebGL2) on browsers without the extension support. Current work is underway with major browsers to support this extension by default in consumer’s browsers.new Rive({...})
instances created.
If you’re planning on displaying Rive content in a list/grid or many times on the same page, it’s up to you to manage the lifecycle of the provided context and canvas
element. If you need to display many animations (i.e grids/lists), consider using the @rive-app/canvas
package which uses the CanvasRenderingContext2D
renderer and does not have a context limitation, or consider the @rive-app/webgl2-advanced
package, which will allow you to display multiple Rive graphics on one canvas with full control over the render loop.
useOffscreenRenderer: true
property in the Rive parameters when creating a new Rive({...})
object, especially when rendering multiple Rive objects on the page.@rive-app/webgl-advanced
will make use of the Rive Renderer completely, without an added Skia dependency@rive-app/webgl2
package plus:
@rive-app/webgl-advanced
, which currently adds a larger Skia dependencyWEBGL_shader_pixel_local_storage
Chrome Extension, otherwise, Rive will fall back to an MSAA solution (also with WebGL2) on browsers without the extension support. Current work is underway with major browsers to support this extension by default in consumer’s browsers.@rive-app/canvas
package plus:
@rive-app/canvas-advanced-lite
below👇@rive-app/canvas-advanced
with the same API and backing CanvasRenderingContext2D, but does not compile and build WASM with certain dependencies in order to keep the package size as small as possible.
This solution will be preferable if you do not have a need for the following features below:
@rive-app/webgl
package plus:
rive.wasm
file. In the high-level APIs (@rive-app/canvas
and @rive-app/webgl
) the runtime requests this for you so you don’t have to, as opposed to their -advanced
counterparts. We also have alternative versions of each of the above packages on NPM that have the WASM encoded in the JS bundle (excluding the lite
versions). This means you won’t have to make a network request for the WASM that powers the Rive animations, as it’s all in one main JS file. This is a solution for if you have issues loading from the CDNs that load in the WASM in your app.