--- url: /guide/getting-started/overview.md --- # Overview ![Demo of react-native-gesture-image-viewer gestures](https://raw.githubusercontent.com/saseungmin/react-native-gesture-image-viewer/main/assets/example.gif) Have you ever struggled with implementing complex gesture handling and animations when building image galleries or content viewers in React Native? Existing libraries often have limited customization options or performance issues. `react-native-gesture-image-viewer` is a high-performance **universal gesture viewer** library built on [**React Native Reanimated**](https://docs.swmansion.com/react-native-reanimated/) and [**Gesture Handler**](https://docs.swmansion.com/react-native-gesture-handler/docs/), providing complete customization and intuitive gesture support for not only images but also videos, custom components, and any other content. ## Key Features - 🀌 **Complete Gesture Support** - Pinch zoom, double-tap zoom, swipe navigation, pan when zoomed-in, and vertical drag to dismiss - 🏎️ **High-Performance Animations** - Smooth and responsive animations at 60fps and beyond, powered by React Native Reanimated - 🎨 **Full Customization** - Total control over components, styles, and gesture behavior - πŸŽ›οΈ **External Control API** - Trigger actions programmatically from buttons or other UI components - 🧩 **Multi-Instance Management** - Manage multiple viewers independently using unique IDs - 🧬 **Flexible Integration** - Use with Modal, [React Native Modal](https://www.npmjs.com/package/react-native-modal), ScrollView, FlatList, [FlashList](https://www.npmjs.com/package/@shopify/flash-list), [Expo Image](https://www.npmjs.com/package/expo-image), [FastImage](https://github.com/DylanVann/react-native-fast-image), and more - 🧠 **Full TypeScript Support** - Great developer experience with type inference and safety - 🌐 **Cross-Platform Support** - Runs on iOS, Android, and Web with Expo Go and New Architecture compatibility - πŸͺ„ **Easy-to-Use API** - Simple and intuitive API that requires minimal setup --- url: /guide/getting-started/installation.md --- # Installation :::warning React Native Reanimated v3 Users If you're using **React Native Reanimated v3**, **version 1.x** of this library is recommended for the best experience. πŸ‘‰ **[Go to v1.x Documentation](/1.x/guide/getting-started/installation.md)** Version 2.x only supports React Native Reanimated v4. ::: :::info Important `react-native-gesture-image-viewer` is a high-performance viewer library built on [`react-native-reanimated`](https://www.npmjs.com/package/react-native-reanimated) and [`react-native-gesture-handler`](https://www.npmjs.com/package/react-native-gesture-handler).\ Therefore, you **must install** React Native Reanimated and Gesture Handler before using this library. Please refer to the official documentation of these libraries for detailed setup guides. ::: #### Minimum Requirements | Library | Minimum Version | | :----------------------------- | :-------------: | | `react` | `>=18.0.0` | | `react-native` | `>=0.75.0` | | `react-native-gesture-handler` | `>=2.24.0` | | `react-native-reanimated` | `>=4.0.0` | | `react-native-worklets` | `>=0.5.0` | ## [React Native Reanimated Setup](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/) ### Install `react-native-reanimated` and `react-native-worklets` packages: ```sh [npm] npm install react-native-reanimated ``` ```sh [yarn] yarn add react-native-reanimated ``` ```sh [pnpm] pnpm add react-native-reanimated ``` ```sh [bun] bun add react-native-reanimated ``` ```sh [deno] deno add npm:react-native-reanimated ``` - `react-native-worklets` was separated from `react-native-reanimated` for better modularity and must be installed separately. ```sh [npm] npm install react-native-worklets ``` ```sh [yarn] yarn add react-native-worklets ``` ```sh [pnpm] pnpm add react-native-worklets ``` ```sh [bun] bun add react-native-worklets ``` ```sh [deno] deno add npm:react-native-worklets ``` ### Configure Babel #### Expo :::warning Expo Go Support To use Reanimated 4 in Expo Go environment, you need to use [Expo SDK 54(beta)](https://expo.dev/go). ::: Run prebuild to update the native code in the ios and android directories. ```sh [npm] npm expo prebuild ``` ```sh [yarn] yarn expo prebuild ``` ```sh [pnpm] pnpm expo prebuild ``` ```sh [bun] bun expo prebuild ``` ```sh [deno] deno expo npm:prebuild ``` And that's it! Reanimated 4 is now configured in your Expo project.\ Since Expo SDK 50, the Expo starter template includes the Reanimated babel plugin by default. #### React Native CLI When using React Native Community CLI, you also need to manually add the `react-native-worklets/plugin` plugin to your `babel.config.js`. ```js title="babel.config.js" module.exports = { presets: [ ... // don't add it here :) ], plugins: [ ... // for web '@babel/plugin-proposal-export-namespace-from', // [!code highlight] // react-native-worklets/plugin has to be listed last. 'react-native-worklets/plugin', // [!code highlight] ], }; ``` ## [React Native Gesture Handler Setup](https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation) ```sh [npm] npm install react-native-gesture-handler ``` ```sh [yarn] yarn add react-native-gesture-handler ``` ```sh [pnpm] pnpm add react-native-gesture-handler ``` ```sh [bun] bun add react-native-gesture-handler ``` ```sh [deno] deno add npm:react-native-gesture-handler ``` - `react-native-gesture-handler` generally doesn't require additional setup, but please refer to the official documentation for your specific environment. - For [using gestures in Android modals](https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation#android), you would normally need to wrap modal content with `GestureHandlerRootView`. However, **this library already includes `GestureHandlerRootView` internally, so no additional wrapping is needed when using modals.** ## Install React Native Gesture Image Viewer You’re all set! πŸŽ‰\ Start by installing `react-native-gesture-image-viewer` ```sh [npm] npm install react-native-gesture-image-viewer ``` ```sh [yarn] yarn add react-native-gesture-image-viewer ``` ```sh [pnpm] pnpm add react-native-gesture-image-viewer ``` ```sh [bun] bun add react-native-gesture-image-viewer ``` ```sh [deno] deno add npm:react-native-gesture-image-viewer ``` --- url: /guide/getting-started/quick-start.md --- # Quick Start ![Demo of react-native-gesture-image-viewer gestures](https://raw.githubusercontent.com/saseungmin/react-native-gesture-image-viewer/main/assets/example.gif) ## Examples & Demo - [πŸ“ Example Project](https://github.com/saseungmin/react-native-gesture-image-viewer/tree/main/example) - Real implementation code with various use cases - [πŸ€– Expo Go](https://snack.expo.dev/@harang/react-native-gesture-image-viewer-v2) - Try it instantly on Expo Snack ## Installation :::warning Important `react-native-gesture-image-viewer` is a high-performance viewer library built on [`react-native-reanimated`](https://www.npmjs.com/package/react-native-reanimated) and [`react-native-gesture-handler`](https://www.npmjs.com/package/react-native-gesture-handler).\ Therefore, you **must install** React Native Reanimated and Gesture Handler before using this library. **If you haven't set it up yet, please refer to the [installation guide](/guide/getting-started/installation.md).** ::: ```sh [npm] npm install react-native-gesture-image-viewer ``` ```sh [yarn] yarn add react-native-gesture-image-viewer ``` ```sh [pnpm] pnpm add react-native-gesture-image-viewer ``` ```sh [bun] bun add react-native-gesture-image-viewer ``` ```sh [deno] deno add npm:react-native-gesture-image-viewer ``` ## Basic Usage `react-native-gesture-image-viewer` is a library focused purely on gesture interactions for complete customization. ```tsx import { useCallback, useState } from 'react'; import { ScrollView, Image, Modal, View, Text, Button, Pressable } from 'react-native'; import { GestureViewer, GestureTrigger, useGestureViewerController, useGestureViewerEvent, useGestureViewerState, } from 'react-native-gesture-image-viewer'; function App() { const images = [...]; const [visible, setVisible] = useState(false); const [selectedIndex, setSelectedIndex] = useState(0); const { goToIndex, goToPrevious, goToNext } = useGestureViewerController(); const { currentIndex, totalCount } = useGestureViewerState(); const openModal = (index: number) => { setSelectedIndex(index); setVisible(true); }; const renderImage = useCallback((imageUrl: string) => { return ; }, []); useGestureViewerEvent('zoomChange', (data) => { console.log(`Zoom changed from ${data.previousScale} to ${data.scale}`); }); return ( {images.map((uri, index) => ( openModal(index)}> ))} setVisible(false)} />