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
useAnimatedStyleboilerplate. - Per-primitive style inference.
Motion.ViewacceptsViewStylekeys,Motion.TextacceptsTextStylekeys, andMotion.ImageacceptsImageStylekeys. There is no shared union fallback, so a wrong prop is a type error. - react-spring vocabulary. A spring config uses
tension,friction,mass, andvelocity. Reanimated's rawstiffnessanddampingnever appear in the public surface. - One
gestureprop on every primitive. The sub-states arepressed,focused,focusVisible(W3C:focus-visible), andhovered(web). There is nowhileTaporwhilePressfamily, 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
animateandtransitionobjects and memoizes the generated worklet anduseAnimatedStyle. 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
- npm
- pnpm
- Bun
yarn add @rootnative/inertia react-native-reanimated react-native-worklets
npm install @rootnative/inertia react-native-reanimated react-native-worklets
pnpm add @rootnative/inertia react-native-reanimated react-native-worklets
bun 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:
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, andMotion.FlatList. - Transitions:
spring(default),timing,decay, andno-animation. - Sequences & repeat: keyframe arrays and the one
repeatshape. - Variants: named animation states and the
useVariantscontroller. - Gestures: the
pressed,focused,focusVisible, andhoveredsub-states. - Gestures adapter: drag, pan, and swipe with
react-native-gesture-handler(optional package). - Gradients: the animatable
MotionLinearGradientonexpo-linear-gradient(optional package). - SVG: the animatable
MotionPathonreact-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.