🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@rive-app/react-canvas

Package Overview
Dependencies
Maintainers
5
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rive-app/react-canvas

React wrapper around the @rive-app/canvas library

4.18.7
Source
npm
Version published
Weekly downloads
227K
7.45%
Maintainers
5
Weekly downloads
 
Created

What is @rive-app/react-canvas?

@rive-app/react-canvas is an npm package that allows you to integrate Rive animations into your React applications. Rive is a powerful tool for creating interactive animations and graphics, and this package provides a way to render these animations on a canvas within a React component.

What are @rive-app/react-canvas's main functionalities?

Rendering Rive Animations

This feature allows you to render a Rive animation by specifying the path to the .riv file. The RiveComponent takes care of loading and displaying the animation.

import { RiveComponent } from '@rive-app/react-canvas';

function App() {
  return (
    <div>
      <RiveComponent src="path/to/animation.riv" />
    </div>
  );
}

export default App;

Controlling Animation State

This feature allows you to control the state of the animation, such as playing or pausing it. The useRive hook provides access to the Rive instance, enabling you to call methods like play() to control the animation.

import { RiveComponent, useRive } from '@rive-app/react-canvas';

function App() {
  const { rive, RiveComponent } = useRive({ src: 'path/to/animation.riv' });

  const playAnimation = () => {
    rive.play();
  };

  return (
    <div>
      <RiveComponent />
      <button onClick={playAnimation}>Play Animation</button>
    </div>
  );
}

export default App;

Handling Animation Events

This feature allows you to handle events related to the animation, such as when it is loaded. The Rive instance provides an event system that you can use to listen for various events.

import { RiveComponent, useRive } from '@rive-app/react-canvas';

function App() {
  const { rive, RiveComponent } = useRive({ src: 'path/to/animation.riv' });

  rive.on('load', () => {
    console.log('Animation loaded');
  });

  return (
    <div>
      <RiveComponent />
    </div>
  );
}

export default App;

Other packages similar to @rive-app/react-canvas

FAQs

Package last updated on 09 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts