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

Here’s a simplified example showing how to integrate the useRiveFile hook to reuse a RiveFile across components:
A file from useRiveFile created with enableGPUCanvas: true can’t be shared across components the way this example shares one — GPU Canvas binds a file to a single <canvas>, so the first Rive component claims it. Call useRiveFile inside each component instead of reusing one file across multiple components. While sharing a file won’t fail; the runtime prints a warning and re-imports the file for each additional Rive instance, which means the file you passed in goes unused. See GPU Canvas.