Skip to main content
Under most circumstances a .riv file should load quickly and managing the RiveFile yourself is not necessary. But if you intend to use the same .riv file in multiple parts of your application, or even on the same screen, it might be advantageous to load the file once and keep it in memory.

Example Usage

The following is a basic example to illustrate how to preload a Rive file, and pass the data to multiple Rive instances.
A RiveFile created with enableGPUCanvas: true can’t be shared across Rive instances the way this example shares one — GPU Canvas binds a file to a single <canvas>, so the first Rive instance claims it. Construct one RiveFile per instance. While sharing the RiveFile in this scenario won’t fail, the runtime prints a warning and re-imports the file for each additional instance, which means the RiveFile you passed in goes unused. See GPU Canvas for more details.