---
title: Animation
description: Learn how to integrate the react-native-reanimated library and use it in your Expo project.
---
import { Terminal, SnackInline } from '~/ui/components/Snippet';
import { BoxLink } from '~/ui/components/BoxLink';
import { BookOpen02Icon } from '@expo/styleguide-icons';
Animations are a great way to enhance and provide a better user experience. In your Expo projects, you can use the [Animated API](https://reactnative.dev/docs/next/animations) from React Native. However, if you want to use more advanced animations with better performance, you can use the [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/) library. It provides an API that simplifies the process of creating smooth, powerful, and maintainable animations.
## Installation
To install `react-native-reanimated`, run the following command:
After the installation completes, add the Babel plugin to **babel.config.js**:
```js babel.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
};
};
```
After you add the Babel plugin, restart your development server and clear the bundler cache using `npx expo start --clear`.
> If you load other Babel plugins, the Reanimated plugin has to be the last item in the plugins array.
### Web support
**For web**, install the [`@babel/plugin-proposal-export-namespace-from`](https://babeljs.io/docs/en/babel-plugin-proposal-export-namespace-from#installation) Babel plugin and update the **babel.config.js** to load it:
{/* prettier-ignore */}
```js babel.config.js
plugins: [
'@babel/plugin-proposal-export-namespace-from',
'react-native-reanimated/plugin',
],
```
After you add the Babel plugin, restart your development server and clear the bundler cache using `npx expo start --clear`.
## Minimal example
The following example shows how to use the `react-native-reanimated` library to create a simple animation. For more information on the API and its usage, see [**`react-native-reanimated` documentation**](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/your-first-animation).
{/* prettier-ignore */}
```jsx
import Animated, {
useSharedValue,
withTiming,
useAnimatedStyle,
Easing,
} from 'react-native-reanimated';
import { View, Button, StyleSheet } from 'react-native';
export default function AnimatedStyleUpdateExample() {
const randomWidth = useSharedValue(10);
const config = {
duration: 500,
easing: Easing.bezier(0.5, 0.01, 0, 1),
};
const style = useAnimatedStyle(() => {
return {
width: withTiming(randomWidth.value, config),
};
});
return (
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
},
box: {
width: 100,
height: 80,
backgroundColor: 'black',
margin: 30,
},
});
```
### Other animation libraries
Other animation packages are available, such as Moti, that you also use in your Expo project and work on Android, iOS, and the web. For more information on its API and usage, see [Moti's documentation](https://moti.fyi/).
## Next step