Skip to main content
Rive’s web runtime comes in two main packages: @rive-app/webgl2 and @rive-app/canvas. They expose the same API. The only difference is how they draw. For most use cases, use @rive-app/webgl2. It draws with the Rive Renderer, the same renderer as the Rive Editor, so everything you can author in Rive renders the way you designed it. @rive-app/canvas uses the browser’s own 2D renderer, which brings its own advantages (particularly for performance), but it does not yet support every Editor feature. Switching is a one-line import change, so you can try both and measure against your own content.

Comparison

Other notable tradeoffs

WebGL context limits

Note that if you’re using @rive-app/webgl2, browsers cap how many WebGL contexts a page can hold at once. The exact number varies by browser and device, and the oldest context is typically dropped once the cap is reached — which limits how many new Rive({...}) instances you can run. See WebGL Context Limits for more details. If you show several graphics on one page, set useOffscreenRenderer: true on each Rive object. Every instance then shares a single offscreen context instead of creating its own, which keeps you under the cap:
This limit does not apply to @rive-app/canvas.

Fill rules

@rive-app/canvas uses the Canvas2D renderer, which offers the non-zero and even-odd fill rules, so Rive’s clockwise fill rule draws as non-zero. The result is identical unless a path has self-intersecting, reversed, or overlapping contours. This applies to both fills and clipping paths.

Performance

Today, @rive-app/webgl2 by default draws through a multisample anti-aliasing (MSAA) path. The Rive Renderer has a faster path to draw that relies on a GPU capability Metal and Vulkan already expose to native apps. On web browsers, it comes from WEBGL_shader_pixel_local_storage, a draft WebGL extension that Rive is helping to standardize. As browsers adopt it, @rive-app/webgl2 will pick it up automatically and draw faster. Until then, there are a few things you can do to get the most out of @rive-app/webgl2:
  1. Use additive blending instead of advanced blend modes where your design allows it.
  2. Opt in to inkbleed antialiasing and measure it against MSAA on your content.

Use additive blending instead of advanced blend modes

On the MSAA path, any blend mode other than Normal (such as Screen, Multiply, or Color Dodge) forces the renderer to re-read the frame as it draws, and that cost adds up very quickly on mobile browsers. Additive blending doesn’t have that cost. In the Editor, it’s authored on a fill, stroke, or drawable set to the Normal blend mode, using the Additive strength slider, from 0% (ordinary Normal blending) to 100% (fully additive). The Rive Renderer draws it with the GPU’s standard hardware blending, the same as Normal, so it doesn’t re-read the frame. Additive strength can also be animated and data bound. If you use blend modes to brighten content, such as glows, fire, light effects, or particles, try additive blending first and keep advanced blend modes for effects that truly need them.
@rive-app/canvas draws additive blending at full strength and ignores the Additive strength amount, since Canvas2D can’t express partial additive blending.

Inkbleed antialiasing

@rive-app/webgl2 can draw with inkbleed, an antialiasing mode in the Rive Renderer offered as an alternative to MSAA. Instead of rendering multiple samples per pixel, it renders one and antialiases edges by bleeding them out about half a pixel, which avoids MSAA’s multisampled buffers. Opt in with enableInkbleed when you create the Rive instance:
Things to know before turning it on:
  • It disables the canvas’s native MSAA. The instance creates its WebGL2 context without MSAA so inkbleed can draw instead.
  • Edges bleed out by about half a pixel. This is most noticeable on thin strokes.
  • Fills are converted to the clockwise fill rule. Fills that use a different fill rule are converted on a best-effort basis, so check your content for visual differences.
  • It needs its own WebGL context. Inkbleed doesn’t apply when using the shared offscreen renderer (useOffscreenRenderer: true), so each instance with inkbleed counts toward the browser’s WebGL context limit.
If the renderer can’t use inkbleed, the runtime logs a one-time console warning and renders without it. Read inkbleed on the Rive instance to check whether it is in effect, or set it to toggle inkbleed at runtime.

Choosing a package for performance

  • Advanced blend modes on mobile are the case where @rive-app/canvas can be meaningfully faster, because Canvas2D blends natively. If your file still leans on them after moving what you can to additive blending, it is worth comparing the two.
  • Measure on real devices. Swapping packages is a one-line change, so testing each option is cheap.

Settling

By default, a playing Rive instance keeps requesting animation frames and advances its state machines on every one, even when nothing on screen is moving. It skips redrawing unchanged frames, but the per-frame advance still runs. When setting enableSettling: true on the Rive instance, the runtime notices when every playing state machine has nothing left to animate and stops there: it no longer advances or draws the graphic, and stops requesting animation frames for it. A graphic that sits idle between interactions then costs no per-frame work until something changes. If a gamepad is connected, the runtime still checks it each frame, but doesn’t advance or draw. The runtime wakes a settled instance and restarts the render loop when something changes, for example:
  • Pointer movement, clicks or scrolling on the canvas, when the graphic has listeners
  • Keyboard input and focus changes
  • Gamepad input
  • Setting state machine inputs or text runs
  • Setting view model property values from JavaScript
  • An asset changing after load, such as an image that finishes decoding
  • Changing the layout or resizing the canvas
If you change something the runtime can’t see, such as writing canvas.width directly, call drawFrame() to resume. You can check isSettled to see whether an instance is currently settled. enableSettling works in both @rive-app/canvas and @rive-app/webgl2. It’s off by default in v2 of the runtime, and will be on by default in the next major version.

Deferred decoding

By default, the runtime decodes the whole .riv file when it loads. With deferDecoding: true set when instantiating Rive, it decodes only what it needs to start, and decodes artboards, animations and view model instances the first time they’re used. The first artboard in the file always decodes at load. This optimization shortens the work done at load for files that hold many artboards, animations or view model instances that a page doesn’t all use. Parts of the .riv the page never uses, apart from the first artboard, generally stay undecoded. deferDecoding works in both canvas and WebGL2 runtime variants. Set it on a RiveFile, or on Rive when it loads the file itself with src or buffer. If you pass a riveFile, set it on the RiveFile instead. It’s off by default.

Canvas package variants

Two variants of the canvas package are available if you have specific bundling needs.

@rive-app/canvas-lite

@rive-app/canvas-lite is the smallest Rive web package. It has the same API and renderer as @rive-app/canvas, but drops the text, layout, audio, and scripting engines, as well as Vector Feathering, to save space. Use it when your files do not rely on those features. If a file does use them, the affected content will not appear.

@rive-app/canvas-single

@rive-app/canvas-single bundles rive.wasm directly into the JavaScript file, so loading Rive takes one network request instead of two. Use it when you want to avoid a separate WASM request. The tradeoff is a larger JavaScript bundle.

Deprecated package

@rive-app/webgl is deprecated and receives no updates after v2.37.0. Move to @rive-app/webgl2, or to @rive-app/canvas if your file does not need the Rive Renderer. Neither move requires API changes — see the migration guide.