.riv files in React apps.
There are three main ways to use Rive in a React app:
- Hooks - use React hooks to render Rive and control state machines, events, and data binding from React.
- Rive component - use the default component for simple embeds with limited runtime control.
- Imperative runtime - use the Web JavaScript runtime directly when you want to create and manage the Rive instance yourself.
Quick Start
1
Install the dependency
This guide uses
@rive-app/react-webgl2. Rive also provides other React packages for different renderers. See Choosing a Renderer to choose the package that fits your project.2
Render the Rive component
- Hooks
- Rive Component
- Imperative
Use the returned
rive instance with other hooks when you need data binding.The Rive canvas sizes itself based on its container. If nothing appears, make sure the parent element has a defined width and height.