Skip to main content

Introduction

Inertia (@rootnative/inertia) is a thin wrapper around react-native-reanimated. You write an animation as props on a component: no shared values, no worklets, no useAnimatedStyle boilerplate. The vocabulary takes ideas from Framer Motion (web) and react-spring (cross-platform).

Inertia supports iOS, Android, and web (react-native-web). macOS, Windows, and Electron are not tested. See Platforms.

Status: 0.0.30. The example app covers the full surface: primitives, per-property transitions, sequences, variants, gestures, <Presence>, decay, <MotionConfig>, layout, shared elements, and the value-layer hooks. The changelog names each breaking change.

What you get​

  • DX-first. Animations are props on a component, not shared values, worklets, and useAnimatedStyle boilerplate.
  • Per-primitive style inference. Motion.View accepts ViewStyle keys, Motion.Text accepts TextStyle keys, and Motion.Image accepts ImageStyle keys. There is no shared union fallback, so a wrong prop is a type error.
  • react-spring vocabulary. A spring config uses tension, friction, mass, and velocity. Reanimated's raw stiffness and damping never appear in the public surface.
  • One gesture prop on every primitive. The sub-states are pressed, focused, focusVisible (W3C :focus-visible), and hovered (web). There is no whileTap or whilePress family, and no separate "pressable" variant.
  • Per-primitive tree-shaking. Subpath imports (@rootnative/inertia/view, /text, /image, /pressable, /scroll-view) let an app that animates one element skip the rest of the library.
  • Stable worklets. The factory hashes the resolved animate and transition objects and memoizes the generated worklet and useAnimatedStyle. A re-render with the same values makes no new UI-thread closure.

Install​

Pick your package manager. Yarn is the default, and your choice applies to every install snippet in the docs.

yarn add @rootnative/inertia react-native-reanimated react-native-worklets

Then enable the react-native-worklets/plugin Babel plugin as the Reanimated install guide shows. Installation has a full babel.config.js.

A first animation​

import { Motion } from '@rootnative/inertia'

export function FadeIn() {
return (
<Motion.View
initial={{ opacity: 0, translateY: 20 }}
animate={{ opacity: 1, translateY: 0 }}
transition={{
opacity: { type: 'timing', duration: 200 },
translateY: { type: 'spring', tension: 180, friction: 12 },
}}
/>
)
}

To ship only one primitive, import it from its subpath:

import { MotionView } from '@rootnative/inertia/view'

Runnable example​

The full example app runs below. It holds every primitive and every gesture, with the same code that ships under example/ in the repo. Tap a screen to try it:

example

Each docs page links to the matching screen of this same app, so you can try the API as you read.

Where to next​

  • Installation: install the peers and the Reanimated Babel plugin.
  • Primitives: Motion.View, Motion.Text, Motion.Image, Motion.Pressable, Motion.ScrollView, and Motion.FlatList.
  • Transitions: spring (default), timing, decay, and no-animation.
  • Sequences & repeat: keyframe arrays and the one repeat shape.
  • Variants: named animation states and the useVariants controller.
  • Gestures: the pressed, focused, focusVisible, and hovered sub-states.
  • Gestures adapter: drag, pan, and swipe with react-native-gesture-handler (optional package).
  • Gradients: the animatable MotionLinearGradient on expo-linear-gradient (optional package).
  • SVG: the animatable MotionPath on react-native-svg (optional package).
  • Presence: mount and unmount transitions.
  • Layout: animate a change of position or size.
  • MotionConfig: the reduce-motion gate and named transitions.
  • Hooks and createMotionComponent: the escape hatches.
  • AI agents & llms.txt: machine-readable API references for coding agents, hosted here and shipped in every npm package.