Getting Started
Drax is a declarative drag-and-drop framework for React Native, written in TypeScript. It supports free-form drag-and-drop, sortable lists and grids, cross-list reorder, drag handles, collision algorithms, and more.
Built on Reanimated 4 and Gesture Handler 3 (v2 also supported) with a UI-thread-first architecture for smooth 60fps interactions.
Platforms: iOS, Android, Web
Installation
npm install react-native-drax
Or with yarn:
yarn add react-native-drax
Peer Dependencies
Drax requires Reanimated and Gesture Handler as peer dependencies. react-native-worklets is required by Reanimated 4, so install it alongside Reanimated:
npm install react-native-reanimated react-native-worklets react-native-gesture-handler
| Peer Dependency | Version |
|---|---|
react | >= 19.0.0 |
react-native | >= 0.78.0 (New Architecture) |
react-native-reanimated | ^4.0.0 |
react-native-gesture-handler | >= 2.0.0 (v3 recommended) |
Gesture Handler v2 and v3 both work. Drax works best with v3; v2 is supported via a compatibility layer with reduced performance.
Reanimated 4 requires the New Architecture and a matching react-native-worklets version (Drax lists worklets as an optional peer, >=0.3.0, since Reanimated 4 already requires it). Check the Reanimated compatibility table to pick versions for your React Native release.
Setup Reanimated
If you haven't already, follow the Reanimated installation guide to add the Babel plugin and any platform-specific setup.
Setup Gesture Handler
Follow the Gesture Handler installation guide. Make sure to wrap your app root with GestureHandlerRootView.
Hello World
Here's a minimal drag-and-drop example:
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { DraxProvider, DraxView } from 'react-native-drax';
import { StyleSheet, Text } from 'react-native';
export default function App() {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<DraxProvider>
<DraxView
style={styles.draggable}
onDragStart={() => console.log('Started dragging!')}
payload="hello"
>
<Text>Drag me</Text>
</DraxView>
<DraxView
style={styles.receiver}
onReceiveDragDrop={({ dragged }) => {
console.log(`Received: ${dragged.payload}`);
}}
>
<Text>Drop here</Text>
</DraxView>
</DraxProvider>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
draggable: {
width: 100,
height: 100,
backgroundColor: '#cf5f34',
borderRadius: 8,
justifyContent: 'center',
alignItems: 'center',
margin: 20,
},
receiver: {
width: 150,
height: 150,
backgroundColor: '#2a9d8f',
borderRadius: 8,
justifyContent: 'center',
alignItems: 'center',
margin: 20,
},
});
That's it! The DraxView is both draggable and receptive by default. Wrap everything in a DraxProvider and you're ready to go.
Key Concepts
DraxProvider— Context provider that manages the drag state. Wrap your drag-and-drop area.DraxView— The core building block. AnyDraxViewcan be dragged, receive drops, or monitor drags.- Payload — Arbitrary data attached to a drag. The receiver gets it on drop.
- Hover Layer — A floating copy of the dragged view that follows your finger.
What's Next?
- Quick Start — Three progressive examples from basic to composable
- Core Concepts — Deep dive into the architecture
- Guides — Feature-specific tutorials
- API Reference — Complete prop and type documentation