Convert Figma logo to code with AI

rive-app logorive-react

React runtime for Rive

1,030
50
1,030
70

Top Related Projects

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/

✌️ A spring physics based React animation library

30,684

A modern animation library for React and JavaScript

🇨🇭 A React renderer for Three.js

25,240

🎥 Make videos programmatically with React

🎊 A collection of animations for inline style libraries

Quick Overview

Rive-react is a React runtime library for Rive animations. It allows developers to easily integrate and control Rive animations within their React applications, providing a seamless way to add interactive and dynamic animations to web projects.

Pros

  • Easy integration with React applications
  • Provides a simple API for controlling Rive animations
  • Supports both StateMachine and Animation playback
  • Offers efficient rendering through WebGL

Cons

  • Limited documentation and examples
  • Requires knowledge of Rive animation creation
  • May have performance issues with complex animations on low-end devices
  • Dependency on the Rive runtime library

Code Examples

  1. Basic Rive animation rendering:
import { useRive } from '@rive-app/react-canvas';

function MyComponent() {
  const { RiveComponent } = useRive({
    src: 'path/to/animation.riv',
    stateMachines: 'State Machine 1',
    autoplay: true,
  });

  return <RiveComponent />;
}
  1. Controlling animation playback:
import { useRive } from '@rive-app/react-canvas';

function AnimationControl() {
  const { rive, RiveComponent } = useRive({
    src: 'path/to/animation.riv',
    animations: 'Animation 1',
    autoplay: false,
  });

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

  return (
    <div>
      <RiveComponent />
      <button onClick={playAnimation}>Play</button>
    </div>
  );
}
  1. Listening to state machine events:
import { useRive, useStateMachineInput } from '@rive-app/react-canvas';

function InteractiveAnimation() {
  const { rive, RiveComponent } = useRive({
    src: 'path/to/animation.riv',
    stateMachines: 'State Machine 1',
  });

  const onClickInput = useStateMachineInput(rive, 'State Machine 1', 'Click');

  const handleClick = () => {
    onClickInput.fire();
  };

  return (
    <div onClick={handleClick}>
      <RiveComponent />
    </div>
  );
}

Getting Started

To get started with rive-react:

  1. Install the package:

    npm install @rive-app/react-canvas
    
  2. Import and use the useRive hook in your React component:

    import { useRive } from '@rive-app/react-canvas';
    
    function App() {
      const { RiveComponent } = useRive({
        src: 'https://cdn.rive.app/animations/vehicles.riv',
      });
    
      return (
        <div>
          <RiveComponent />
        </div>
      );
    }
    
  3. Make sure to have a Rive animation file (.riv) ready to use in your project.

Competitor Comparisons

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/

Pros of Lottie-web

  • Wider adoption and community support
  • Extensive documentation and examples
  • Supports a broader range of animation features

Cons of Lottie-web

  • Larger file size for complex animations
  • Limited runtime manipulation of animations
  • Steeper learning curve for designers

Code Comparison

Rive-react:

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

function Animation() {
  const { RiveComponent } = useRive({
    src: 'animation.riv',
    stateMachines: 'State Machine 1',
  });

  return <RiveComponent />;
}

Lottie-web:

import lottie from 'lottie-web';
import animationData from './animation.json';

function Animation() {
  useEffect(() => {
    lottie.loadAnimation({
      container: document.getElementById('lottie-container'),
      renderer: 'svg',
      loop: true,
      autoplay: true,
      animationData: animationData,
    });
  }, []);

  return <div id="lottie-container" />;
}

Both libraries offer React integration for adding animations to web applications. Rive-react provides a more straightforward API with built-in React hooks, while Lottie-web requires more setup but offers greater flexibility in animation control.

✌️ A spring physics based React animation library

Pros of react-spring

  • More versatile for general-purpose animations and transitions
  • Larger community and ecosystem with extensive documentation
  • Physics-based animations for more natural-looking effects

Cons of react-spring

  • Steeper learning curve for complex animations
  • May require more code for simple animations compared to Rive
  • Not specifically designed for vector graphics or interactive animations

Code Comparison

react-spring:

import { useSpring, animated } from 'react-spring'

function AnimatedComponent() {
  const props = useSpring({ opacity: 1, from: { opacity: 0 } })
  return <animated.div style={props}>I will fade in</animated.div>
}

rive-react:

import { useRive } from 'rive-react'

function RiveComponent() {
  const { RiveComponent } = useRive({
    src: 'animation.riv',
    stateMachines: 'State Machine 1',
    autoplay: true,
  })
  return <RiveComponent />
}

Summary

react-spring is a powerful and flexible animation library for React applications, offering physics-based animations and a large ecosystem. However, it may have a steeper learning curve for complex animations. rive-react, on the other hand, is specifically designed for vector graphics and interactive animations, making it easier to implement certain types of animations but potentially less versatile for general-purpose use.

30,684

A modern animation library for React and JavaScript

Error generating comparison

🇨🇭 A React renderer for Three.js

Pros of react-three-fiber

  • More powerful and flexible for complex 3D scenes and animations
  • Larger ecosystem with extensive documentation and community support
  • Integrates seamlessly with other Three.js libraries and tools

Cons of react-three-fiber

  • Steeper learning curve, especially for developers new to 3D graphics
  • Higher performance overhead for simpler 2D animations
  • Requires more code to achieve basic animations compared to Rive

Code Comparison

react-three-fiber:

import { Canvas } from '@react-three/fiber'
import { Box } from '@react-three/drei'

function Scene() {
  return (
    <Canvas>
      <Box position={[0, 0, 0]} />
    </Canvas>
  )
}

rive-react:

import { useRive } from 'rive-react'

function Animation() {
  const { RiveComponent } = useRive({
    src: 'animation.riv',
    stateMachines: 'State Machine 1'
  })
  return <RiveComponent />
}

The react-three-fiber example demonstrates creating a 3D scene with a simple box, while the rive-react example shows how to load and display a pre-made Rive animation. react-three-fiber offers more control over individual elements, while rive-react provides a more streamlined approach for pre-designed animations.

25,240

🎥 Make videos programmatically with React

Pros of Remotion

  • Offers more flexibility for creating complex video animations using React
  • Provides a wider range of video editing capabilities, including audio manipulation
  • Supports server-side rendering for generating videos programmatically

Cons of Remotion

  • Steeper learning curve due to its more comprehensive feature set
  • Larger bundle size and potentially higher resource usage
  • May be overkill for simpler animation needs

Code Comparison

Rive React:

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

function MyComponent() {
  const { rive, RiveComponent } = useRive({
    src: 'animation.riv',
    stateMachines: 'State Machine 1',
  });

  return <RiveComponent />;
}

Remotion:

import { Composition } from 'remotion';
import { MyAnimation } from './MyAnimation';

export const RemotionVideo = () => {
  return (
    <Composition
      id="MyAnimation"
      component={MyAnimation}
      durationInFrames={60}
      fps={30}
      width={1920}
      height={1080}
    />
  );
};

Both libraries offer React-based solutions for creating animations, but Rive React focuses on lightweight, interactive animations using Rive files, while Remotion provides a more comprehensive toolkit for creating full-fledged videos with React components.

🎊 A collection of animations for inline style libraries

Pros of react-animations

  • Lightweight and focused solely on CSS animations
  • Easy to integrate with existing React projects
  • Provides a wide range of pre-defined animations

Cons of react-animations

  • Limited to CSS-based animations, lacking advanced features
  • Requires additional styling libraries for full implementation
  • Less suitable for complex, interactive animations

Code Comparison

react-animations:

import { bounce } from 'react-animations';
import styled, { keyframes } from 'styled-components';

const Bounce = styled.div`animation: 2s ${keyframes`${bounce}`} infinite`;

return <Bounce>Bouncing text!</Bounce>;

rive-react:

import { useRive } from 'rive-react';

function RiveComponent() {
  const { RiveComponent } = useRive({
    src: 'animation.riv',
    stateMachines: 'State Machine 1',
    autoplay: true,
  });

  return <RiveComponent />;
}

react-animations focuses on simple CSS-based animations, making it easy to implement basic effects with minimal setup. It's lightweight and integrates well with styled-components or other CSS-in-JS solutions.

rive-react, on the other hand, provides a more powerful animation system based on Rive animations. It supports complex, interactive animations with state machines and runtime manipulation, making it suitable for more advanced use cases.

While react-animations is easier to get started with for simple effects, rive-react offers greater flexibility and control for creating rich, interactive animations in React applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Build Status Discord badge Twitter handle

Rive React

Rive hero image

Rive combines an interactive design tool, a new stateful graphics format, a lightweight multi-platform runtime, and a blazing-fast vector renderer. This end-to-end pipeline guarantees that what you build in the Rive Editor is exactly what ships in your apps, games, and websites.

This library is a wrapper around the JS/Wasm runtime, giving full control over the JS/Wasm runtime while providing components and hooks for React applications.

For more information, check out the following resources:

Table of contents

Rive overview

Rive is a real-time interactive design and animation tool that helps teams create and run interactive animations anywhere. Designers and developers use our collaborative editor to create motion graphics that respond to different states and user inputs. Our lightweight open-source runtime libraries allow them to load their animations into apps, games, and websites.

:house_with_garden: Homepage

:blue_book: General help docs

🛠 Rive Forums

Getting started

Follow along with the link below for a quick start in getting Rive React integrated into your React apps.

For more information, see the Runtime sections of the Rive help documentation:

Supported versions

This library supports React versions ^16.8.0 through ^18.0.0.

Examples

Check out our Storybook instance that shows how to use the library in small examples, along with code snippets! This includes examples using the basic component, as well as the convenient hooks exported to take advantage of state machines.

Awesome Rive

For even more examples and resources on using Rive at runtime or in other tools, checkout the awesome-rive repo.

Migration guides

Using an older version of the runtime and need to learn how to upgrade to the latest version? Check out the migration guides below in our help center that help guide you through version bumps; breaking changes and all!

Migration guides

Contributing

We love contributions! Check out our contributing docs to get more details into how to run this project, the examples, and more all locally.

Issues

Have an issue with using the runtime, or want to suggest a feature/API to help make your development life better? Log an issue in our issues tab! You can also browse older issues and discussion threads there to see solutions that may have worked for common problems.

NPM DownloadsLast 30 Days