--- url: /1.x/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/docs/3.x/fundamentals/getting-started/) 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: /1.x/guide/getting-started/installation.md --- # Installation :::warning React Native Reanimated v4 Users If you're using **React Native Reanimated v4**, **version 2.x** of this library is recommended for the best experience. - πŸ‘‰ **[Go to v2.x Documentation](/guide/getting-started/installation.md)** - πŸ“– **[Migration Guide from 1.x to 2.x](/guide/migration-from-1.x.md)** While v1.x may work with Reanimated v4, it's optimized for v3 and you might encounter deprecation warnings or compatibility issues. ::: :::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` | `>=3.0.0` | ## [React Native Reanimated Setup](https://docs.swmansion.com/react-native-reanimated/docs/3.x/fundamentals/getting-started/) ```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 ``` ### Add the 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-reanimated/plugin has to be listed last. 'react-native-reanimated/plugin', // [!code highlight] ], }; ``` ### Wrap your Metro config with `wrapWithReanimatedMetroConfig` in `metro.config.js`: ```js title="metro.config.js" // [!code highlight:3] const { wrapWithReanimatedMetroConfig } = require('react-native-reanimated/metro-config'); const config = { // Your existing Metro configuration options }; module.exports = wrapWithReanimatedMetroConfig(config); // [!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@1.x ``` ```sh [yarn] yarn add react-native-gesture-image-viewer@1.x ``` ```sh [pnpm] pnpm add react-native-gesture-image-viewer@1.x ``` ```sh [bun] bun add react-native-gesture-image-viewer@1.x ``` ```sh [deno] deno add npm:react-native-gesture-image-viewer@1.x ``` --- url: /1.x/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/v1.x/example) - Real implementation code with various use cases - [πŸ€– Expo Go](https://snack.expo.dev/@harang/react-native-gesture-image-viewer) - Try it instantly on Snack Expo ## 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](/1.x/guide/getting-started/installation.md).** ::: ```sh [npm] npm install react-native-gesture-image-viewer@1.x ``` ```sh [yarn] yarn add react-native-gesture-image-viewer@1.x ``` ```sh [pnpm] pnpm add react-native-gesture-image-viewer@1.x ``` ```sh [bun] bun add react-native-gesture-image-viewer@1.x ``` ```sh [deno] deno add npm:react-native-gesture-image-viewer@1.x ``` ## 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 } from 'react-native'; import { GestureViewer, GestureTrigger, useGestureViewerController, useGestureViewerEvent } from 'react-native-gesture-image-viewer'; function App() { const images = [...]; const [visible, setVisible] = useState(false); const [selectedIndex, setSelectedIndex] = useState(0); const { goToIndex, goToPrevious, goToNext, currentIndex, totalCount } = useGestureViewerController(); 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)} />