# Migrate from react-native-pager-view

> Switch from react-native-pager-view to Patine UI's Pager: swipeable pages with no native module, value and onValueChange instead of refs, optional dots, vertical paging and arrow keys on the web. Works in Expo Go and the browser.

# Migrate from `react-native-pager-view`

```diff
- import PagerView from 'react-native-pager-view';
+ import { Pager } from 'patine-ui';

- <PagerView style={{ flex: 1 }} initialPage={0} onPageSelected={(e) => setPage(e.nativeEvent.position)} ref={pager}>
+ <Pager style={{ flex: 1 }} value={page} onValueChange={setPage}>
    <Welcome key="1" />
    <Features key="2" />
- </PagerView>
+ </Pager>

- pager.current?.setPage(1);
+ setPage(1);
```

| react-native-pager-view | Patine UI |
| --- | --- |
| `initialPage` | `defaultValue`, or `value` to control it |
| `onPageSelected` | `onValueChange(index)`, once a page settles |
| `setPage(i)` / `setPageWithoutAnimation(i)` | set `value` (it scrolls without calling `onValueChange`; instant when the OS reduces motion) |
| `scrollEnabled` | `scrollEnabled` |
| `orientation="vertical"` | `orientation="vertical"` |
| `pageMargin` | `gap` |
| `onPageScroll` / `onPageScrollStateChanged` | — |
| `offscreenPageLimit` | — (every page renders) |
| `overdrag` / `overScrollMode` / `keyboardDismissMode` | — |

[`Pager`](../../components/carousel#pager) is a paging `ScrollView`, so it needs no native module, runs in Expo Go and on the web (where arrow keys page it), and pairs with `PageIndicator` for dots. For slides narrower than the screen, loop or autoplay, use `Carousel`.

See [all migration guides](./index.mdx) for other libraries, and [Comparison](../comparison.mdx) for when another library is the better choice.
