---
title: "Rive: Animations That React to Clicks, Data and AI"
author: "Ecem Karaman"
source: "https://aiwithecem.com/guides/rive-interactive-animations"
published: 2026-11-10
tools: ["Claude","Multi-Tool"]
topics: ["Building","Creative"]
---

# Rive: Animations That React to Clicks, Data and AI

Rive is a tool for making animations that react to what's happening: a button that squishes when you press it, a character that follows your cursor, a mascot that reacts while you talk to it. You design the animation in Rive's editor, and the same file then runs on websites, in iOS and Android apps, and in games built with Unity or Unreal. Where [Three.js](/guides/threejs-3d-website) is mostly about 3D you write in code, Rive is about graphics you design first and then control with code. It's also one of the first creative tools built to work with coding agents. Below is how a Rive file is put together, where AI fits in, and some projects worth studying.

> **In this guide**
>
> 1. [What Rive does](#what-rive-does)
> 2. [The six pieces of a Rive file](#the-six-pieces-of-a-rive-file)
> 3. [How they work together](#how-they-work-together)
> 4. [Where AI fits](#where-ai-fits)
> 5. [Pick your setup](#pick-your-setup)
> 6. [Ship it without surprises](#ship-it-without-surprises)
> 7. [Projects worth studying](#projects-worth-studying)
> 8. [Your first build](#your-first-build)

## What Rive does

A video or GIF plays the same way every time. Rive files contain the animations *and* the logic that decides which one plays, when, and how it blends into the next, based on clicks, hovers or data from your app.

You build in the Rive Editor (browser or desktop), export a small `.riv` file, and load it on your site with Rive's open-source runtime. The same file works on the web, iOS, Android, Flutter, Unity and Unreal.

If you've used Lottie: it started as a way to [play After Effects animations](https://airbnb.io/lottie/) in apps. Rive's editor is built around interaction and live data from the start.

## The six pieces of a Rive file

| Piece | What it is | Think of it as |
| ----- | ---------- | -------------- |
| **Artboard** | The canvas for one graphic, with its own size, shapes, animations and logic | The stage |
| **Shapes and components** | Vector artwork, images, text and reusable nested artboards. Bones and meshes let you rig a character | The cast |
| **Timeline** | One animation made of keyframes: "blink", "wave", "idle breathing" | A rehearsed move |
| **State machine** | Decides which timeline plays and when to switch. Made of states, transitions with conditions, layers that run at once, and listeners for pointer and keyboard events | The director |
| **View model** | The data the file exposes: numbers, text, colors, true/false, choices, triggers. Bound to properties in the scene | The script your app hands in |
| **Runtime** | The library that draws the file and lets your code read and set its data | The theater |

Older tutorials talk about state machine **inputs**. Rive now recommends **data binding** (view models) for new work, so start there.

## How they work together

Picture a mascot with three timelines: idle, thinking and happy. The state machine starts in idle. A transition says "go to thinking when `mood` is thinking", another says "go to happy when `celebrate` fires", and Rive blends between them. Your website never touches the animations. It only changes data.

Loading a file takes a few lines. This is the official example, using a public demo file:

```js
import { Rive } from "@rive-app/webgl2";

const r = new Rive({
  src: "https://cdn.rive.app/animations/vehicles.riv",
  canvas: document.getElementById("canvas"),
  stateMachine: "bumpy",
  autoplay: true,
  autoBind: true,
  onLoad: () => r.resizeDrawingSurfaceToCanvas(),
});
```

Talking to it uses the view model. For the mascot above (property names are whatever you defined in the editor):

```js
const vm = r.viewModelInstance;
vm.enum("mood").value = "thinking";     // switch state
vm.string("message").value = "Hi!";     // update text in the graphic
vm.trigger("celebrate").trigger();      // fire a one-off reaction
```

That split is the useful part. The designer owns how it moves, the developer owns what it means, and the file is the contract between them.

## Where AI fits

Rive now ships three official ways for AI to build *inside* the file, not just the code around it.

| Option | Where you prompt | What it can do | Good for |
| ------ | ---------------- | -------------- | -------- |
| **[AI Agent](https://rive.app/docs/editor/ai-agent/ai-agent)** | Inside the Rive Editor | Shapes, layouts, rigging, timelines, state machines, view models, scripts. Every plan includes it; Free and Cadet have usage limits | Help while you design by hand |
| **[Rive CLI](https://rive.app/docs/cli/agents)** | Claude Code, Cursor or another coding agent | Writes the scene in Rive's text format (RML), builds the `.riv`, previews, screenshots and checks its own work | Working from your code editor and Git |
| **[MCP](https://rive.app/docs/editor/ai/mcp)** | Claude Code or Cursor, connected to the desktop editor | Edits the open file: artboards, shapes, bones, state machines, data binding, scripts | Repetitive setup, like a state machine with dozens of states |

`rive create` even writes a `CLAUDE.md` into the new project, so your agent knows how to look up types and verify what it built. Rive's own advice is to build in stages (rough layout, then structure, then detail) so you can catch problems early. Timing, character and feel are still your call.

## Pick your setup

| If your site is... | Use | Why |
| ------------------ | --- | --- |
| Plain HTML, Webflow or WordPress | **`@rive-app/webgl2`** (script tag or npm) | Draws with the same renderer as the editor, so it looks the way you designed it |
| React or Next.js | **`@rive-app/react-webgl2`** | Hooks for loading the file and reading or setting view model data |
| A page with many small graphics | **`@rive-app/canvas`** | Uses the browser's 2D renderer, with no limit on graphics per page, but doesn't match every editor feature |
| Simple graphics with no text, layouts, scripts or audio | **`@rive-app/canvas-lite`** | The smallest package |

The packages share the same API, so switching is a one-line import change. On the Free plan, exported `.riv` files show a Rive splash screen. The $9/month Cadet plan removes it.

## Ship it without surprises

- **Name the state machine.** Pass `stateMachine` when you load. Without it, the runtime may only play the first timeline it finds.
- **Keep it sharp.** Call `resizeDrawingSurfaceToCanvas()` on load and on window resize, or it'll look blurry on high-density screens.
- **Give the container a size.** The React canvas sizes itself to its parent. If nothing shows up, the parent has no width or height.
- **Several graphics on one page?** Browsers cap WebGL contexts, so with `webgl2` set `useOffscreenRenderer: true` to share one.
- **Make it accessible.** A canvas is invisible to screen readers. Rive can build an accessible layer from roles and labels you set in the editor, but it's opt-in and experimental. Keep important text and buttons in normal HTML too.
- **Respect reduced motion.** Check `prefers-reduced-motion` and show a calm or final state instead of the full animation.

## Projects worth studying

- **[Duolingo's Video Call with Lily](https://rive.app/blog/duolingo-s-ai-powered-video-call-brings-lily-to-life):** an AI conversation partner whose mouth, expressions and camera moves run on a Rive state machine. Instead of animating every reaction, it blends modular pieces, and she ponders during processing delays instead of freezing. The file is under a megabyte. A good look at an AI interface that isn't a chat window.
- **[Spotify Wrapped 2025](https://rive.app/blog/spotify-used-rive-for-spotify-wrapped-2025):** designers prototyped with dummy data, then engineers drove the same animations with each user's real data.
- **[Strava Year in Sport](https://rive.app/blog/strava-year-in-sport-built-with-rive):** one data-bound file built personalized recaps for 5.87 million athletes in 14 languages.
- **[Rive Marketplace](https://rive.app/marketplace):** community files you can open and remix. The fastest way to see how someone else built a state machine.
- **[Runtime demos](https://rive.app/docs/runtimes/demos):** small working examples of the code side, from basic playback to data binding.

## Your first build

Ask first: does this graphic need to *react* to something? If it plays the same way every time, a video or CSS animation is simpler.

If yes, pick a path:

1. **Remix, then wire.** Open a Marketplace file in the editor, find its state machine and view model, export it, and load it with the code above.
2. **Have your agent build it.** Install the [Rive CLI](https://rive.app/docs/cli/getting-started) (macOS on Apple Silicon, Linux or Windows), run `rive create mascot`, then `rive mascot` for the live preview. Open the folder in Claude Code and paste:

```text
Build a small mascot for my website in this Rive project. Work in stages and check with me after each: first a simple shape-based character, then three timelines (idle breathing, thinking, happy bounce), then a state machine that switches between them. Expose a view model with an enum "mood" (idle, thinking, happy) and a trigger "celebrate". Verify and screenshot after each stage. Then give me the minimal @rive-app/webgl2 code to load the .riv on a web page and set mood from JavaScript.
```

Either way, watch Rive's [Quick Start tutorial](https://www.youtube.com/watch?v=u2kThOXc3Ek) first. Seeing a state machine built by hand makes everything above easier to steer.

**Details checked against [Rive's docs](https://rive.app/docs/getting-started/introduction), [pricing](https://rive.app/pricing) and the linked case studies on November 10, 2026.**

**Go deeper:** [State machines](https://rive.app/docs/editor/state-machine/state-machine) · [Data binding](https://rive.app/docs/editor/data-binding/overview) · [Canvas vs WebGL2](https://rive.app/docs/runtimes/web/canvas-vs-webgl) · [Three.js: real-time 3D you build with code](/guides/threejs-3d-website)
