Skip to content

About

A powerful, performant drag-and-drop library for React Native built on Reanimated 4 and Gesture Handler. Smooth 60fps animations, sortable lists & grids, collision detection, and full TypeScript support.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

ย 
ย 

Latest commit

ย 

History

165 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

React Native Reanimated DnD ๐ŸŽฏ

launch-video.mp4

A drag-and-drop library that finally works on React Native โœจ

Powerful, performant, and built for the modern React Native developer

npm version License: MIT TypeScript React Native


NPM Package Documentation Live Demo

๐Ÿš€ Why This Library?

After countless attempts with drag-and-drop solutions that don't work or are simply outdated, this is something that finally works. And it is not just another DnD library, but a complete ecosystem built from the ground up for React Native, offering a best-in-class developer experience and production-ready performance.

Highly feature-packed with every interaction pattern you'll ever need, yet simple enough to get started in minutes. Built for developers who demand both power and simplicity.

โœจ Features

  • ๐Ÿš€ High Performance - Built with Reanimated 4 and Worklets for buttery-smooth 60fps animations
  • ๐Ÿ—๏ธ New Architecture Ready - Built for the modern React Native architecture used by Expo SDK 55+
  • ๐Ÿ“ฆ Expo Compatible - Tested against Expo SDK 55 and React Native 0.83
  • ๐Ÿชถ Tiny Bundle Size - Only 70kb unpacked size, won't bloat your app
  • ๐ŸŽฏ Flexible API - From simple drag-and-drop to complex sortable lists
  • ๐Ÿ“ฑ React Native First - Designed specifically for mobile, not ported from web
  • ๐Ÿ”ง TypeScript Ready - Full type safety with comprehensive definitions
  • ๐ŸŽจ Infinitely Customizable - Every animation, behavior, and style is configurable
  • ๐Ÿ“ฆ Complete Component Suite - Draggable, Droppable, Sortable, and more
  • ๐ŸŽช Smart Collision Detection - Multiple algorithms (center, intersect, contain)
  • ๐Ÿ“œ Vertical & Horizontal Sortable Lists - Drag and drop to sort lists in any direction with automatic scrolling
  • ๐Ÿ”ฒ Sortable Grids - 2D grid drag-and-drop with flexible layouts, insert and swap modes
  • โ†• Dynamic Heights - Sortable lists with variable item heights
  • โšก FlatList Performance - Optional FlatList rendering for large datasets with virtualization
  • ๐ŸŽญ Drag Handles - Precise control with dedicated drag areas
  • ๐ŸŽฌ Custom Animations - Spring, timing, or bring your own animation functions
  • ๐Ÿ“ Pixel-Perfect Positioning - 9-point alignment system with custom offsets
  • ๐Ÿ“ฆ Boundary Constraints - Keep draggables within specific areas
  • โšก State Management - Complete lifecycle tracking and callbacks
  • ๐ŸŽฏ Developer Experience - Intuitive APIs, helpful warnings, and extensive examples

๐Ÿ“ฑ Interactive Examples

See it in action! A comprehensive example app with 18 interactive demos showcasing every feature and use case.

๐ŸŽฎ Try the Example App

๐Ÿ“ฑ Scan & Play

Expo QR Code

Scan with Expo Go to try the demo instantly

๐Ÿš€ Quick Start

  1. Install Expo Go on your phone (SDK 55)
  2. Scan the QR code with your camera
  3. Explore 18 interactive examples!

Or browse the code: ๐Ÿ“‚ View Example App โ†’

๐Ÿ“š Complete Documentation

Documentation

Comprehensive guides, API reference, and interactive examples

The example app includes:

  • ๐ŸŽต Sortable Music Queue - Complete list reordering with drag handles
  • โ‡Œ Horizontal Sortable - Reorderable horizontal scrolling list
  • ๐Ÿ”ฒ Sortable Grid - 2D grid reordering with insert/swap modes
  • โ†• Dynamic Heights - Sortable list with variable item heights
  • ๐ŸŽฏ Basic Drag & Drop - Drag items to drop zones with pre-drag delay
  • ๐ŸŽช Drag Handles - Dedicated drag regions for precise control
  • ๐ŸŽฌ Custom Animations - Spring, timing, bounce & easing curves
  • โœจ Active Drop Styles - Visual feedback on hover
  • ๐Ÿ“ Alignment & Offset - Precise drop positioning with offsets
  • ๐Ÿ“ฆ Boundary Constraints - Axis-locked and bounded dragging
  • ๐ŸŽฏ Collision Detection - Center, intersect & contain algorithms
  • ๐Ÿ—บ๏ธ Dropped Items Map - Track items across multiple zones
  • โšก Drag State - State enum & onStateChange lifecycle
  • โš™๏ธ Custom Draggable - useDraggable hook implementation

๐ŸŽฌ Demo Showcase

๐ŸŽต Sortable Music Queue

Vertical list reordering with drag handles

sortable-music-queue.mp4

Features: Auto-scrolling โ€ข Drag handles โ€ข Smooth transitions

โ‡Œ Horizontal Sortable

Reorderable horizontal scrolling list

horizontal-sortable.mp4

Features: Horizontal scroll โ€ข Handle & full item modes

๐Ÿ”ฒ Grid Sortable

2D grid reordering with insert & swap

grid-sortable.mp4

Features: Grid layout โ€ข Insert & swap modes

โ†• Dynamic Heights

Sortable list with variable item heights

dynamic-heights.mp4

Features: Variable heights โ€ข Expand/collapse โ€ข Auto-scroll

๐ŸŽฏ Basic Drag & Drop

Drag items to drop zones

basic-drag-drop.mp4

Features: Drop zones โ€ข Pre-drag delay โ€ข Visual feedback

๐ŸŽญ Drag Handles

Dedicated regions for drag control

drag-handles.mp4

Features: Full handle โ€ข Bar handle โ€ข Header handle

โœจ Active Drop Styles

Visual hover effects on drop zones

active-drop-styles.mp4

Feedback: Pulse effect โ€ข Glow effect โ€ข Hover states

๐Ÿ“ Alignment & Offset

Precise drop positioning with offsets

alignment-offset.mp4

Features: 9-point alignment โ€ข X/Y offset controls

๐Ÿ“ฆ Bounded Dragging

Constrain movement within boundaries

bounded-dragging.mp4

Constraints: Container bounds โ€ข Axis-locked โ€ข Custom limits

๐ŸŽช Collision Detection

Center, intersect & contain algorithms

collision-detection.mp4

Algorithms: Center โ€ข Intersect โ€ข Contain

๐Ÿ—บ๏ธ Dropped Items Map

Track items across multiple zones

dropped-items-map.mp4

Features: Multi-zone tracking โ€ข Real-time mapping

โšก Drag State

State lifecycle tracking & callbacks

drag-state.mp4

States: Idle โ€ข Dragging โ€ข Dropped

๐Ÿš€ Installation

npm install react-native-reanimated-dnd

Peer Dependencies

npm install react-native-reanimated react-native-gesture-handler react-native-worklets

Follow the setup guides:

Make sure your Babel config uses "react-native-worklets/plugin" as the last plugin and that your app is running on the New Architecture, which is required by Reanimated 4.

๐Ÿ“‹ Requirements

Data Structure

All items in your data array MUST have an id property of type string:

interface YourDataType {
  id: string; // Required!
  // ... your other properties
}

This is essential for the library to track items during reordering.

Example:

// โœ… Good - Each item has a unique string id
const tasks = [
  { id: "1", title: "Learn React Native", completed: false },
  { id: "2", title: "Build an app", completed: false },
  { id: "3", title: "Deploy to store", completed: true },
];

// โŒ Bad - Missing id properties
const badTasks = [{ title: "Task 1" }, { title: "Task 2" }];

// โŒ Bad - Non-string ids
const badTasksWithNumbers = [
  { id: 1, title: "Task 1" },
  { id: 2, title: "Task 2" },
];

The library includes runtime validation in development mode that will warn you if items are missing valid ID properties.

State Management Guidelines

IMPORTANT: Sortable components maintain their own internal state for optimal performance and animation consistency.

Do NOT Do This

  • Never update external state (arrays, Redux, Zustand, etc.) directly in onMove callbacks
  • Never call setItems(), setTasks(), or similar functions during drag operations
  • Never manually splice or reorder external arrays in response to drag events

Correct Approach

  • Use onMove for logging, analytics, or side effects only
  • Use onDrop with allPositions parameter for read-only position tracking
  • Let sortable components handle their internal reordering automatically
  • Use external state only for the initial data and for non-reordering updates

Future Features

Programmatic list operations (add, update, delete, reorder items) that work correctly with internal state management will be added in upcoming releases. This will provide safe methods to modify sortable lists externally.

๐Ÿƒโ€โ™‚๏ธ Quick Start

Basic Drag & Drop

import { GestureHandlerRootView } from "react-native-gesture-handler";
import { Draggable, Droppable, DropProvider } from "react-native-reanimated-dnd";

export default function App() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <DropProvider>
        <Droppable onDrop={(data) => console.log("Dropped:", data)}>
          <View style={styles.dropZone}>
            <Text>Drop here</Text>
          </View>
        </Droppable>

        <Draggable data={{ id: "1", title: "Drag me!" }}>
          <View style={styles.item}>
            <Text>Drag me around!</Text>
          </View>
        </Draggable>
      </DropProvider>
    </GestureHandlerRootView>
  );
}

Sortable List

import { Sortable, SortableItem, SortableRenderItemProps } from "react-native-reanimated-dnd";

const tasks = [
  { id: "1", title: "Learn React Native" },
  { id: "2", title: "Build an app" },
  { id: "3", title: "Deploy to store" },
];

function TaskList() {
  const renderItem = useCallback((props: SortableRenderItemProps<typeof tasks[0]>) => {
    const { item, id, ...rest } = props;
    return (
      <SortableItem key={id} id={id} data={item} {...rest}>
        <View style={styles.task}>
          <Text>{item.title}</Text>
          <SortableItem.Handle>
            <Text>โ‹ฎโ‹ฎ</Text>
          </SortableItem.Handle>
        </View>
      </SortableItem>
    );
  }, []);

  return <Sortable data={tasks} renderItem={renderItem} itemHeight={60} />;
}

Sortable Grid

import { SortableGrid, SortableGridItem } from "react-native-reanimated-dnd";

const apps = [
  { id: "1", label: "Photos" },
  { id: "2", label: "Music" },
  { id: "3", label: "Settings" },
  { id: "4", label: "Mail" },
];

function AppGrid() {
  const renderItem = useCallback((props) => {
    const { item, id, ...rest } = props;
    return (
      <SortableGridItem key={id} id={id} {...rest}>
        <View style={styles.gridItem}>
          <Text>{item.label}</Text>
        </View>
      </SortableGridItem>
    );
  }, []);

  return (
    <SortableGrid
      data={apps}
      renderItem={renderItem}
      dimensions={{ columns: 4, itemWidth: 80, itemHeight: 80, rowGap: 12, columnGap: 12 }}
    />
  );
}

More examples: Quick Start Guide ยท Sortable Lists ยท Sortable Grids ยท All Examples

๐Ÿ“š Documentation

Visit reanimated-dnd-docs.vercel.app for the full documentation:

  • Getting Started โ€” Installation, setup, and quick start
  • Components โ€” Draggable, Droppable, Sortable, SortableGrid, SortableItem
  • Hooks โ€” useDraggable, useDroppable, useSortable, useGridSortable
  • Guides โ€” Animations, collision algorithms, performance, accessibility
  • Examples โ€” Interactive code examples for every feature
  • API Reference โ€” Complete types, enums, and utilities

๐Ÿƒโ€โ™‚๏ธ Running the Example App

  1. Clone the repository:
git clone https://github.com/entropyconquers/react-native-reanimated-dnd.git
cd react-native-reanimated-dnd
  1. Install dependencies (uses npm workspaces):
npm install
  1. Run the example app:
# iOS
npm run start --workspace example-app
# then press 'i' for iOS or 'a' for Android

# Or run directly:
npx expo run:ios --cwd example-app
npx expo run:android --cwd example-app

Note: Reanimated 4 requires the New Architecture, so you must use a development build (npx expo run:ios / npx expo run:android), not Expo Go.

The example app includes all 18 interactive examples showcasing every feature of the library.

๐Ÿ—บ๏ธ Project Roadmap

I am constantly working to improve React Native Reanimated DnD. Here's what's coming next:

โœ… v2.0.0 (Current)

Reanimated 4 + Worklets Migration

  • ๐Ÿš€ Reanimated 4 & Worklets - Migrated from Reanimated 3 to Reanimated 4 with react-native-worklets
  • ๐Ÿ—๏ธ New Architecture - Built for React Native's New Architecture (required by Reanimated 4)
  • ๐Ÿ“ฆ Expo SDK 55 - Tested and compatible with Expo SDK 55 and React Native 0.83
  • ๐Ÿ”ง Handle Registration - Replaced tree-walking handle detection with a registration pattern
  • โšก Improved Scheduling - Uses scheduleOnRN/scheduleOnUI for better worklet-to-JS communication
  • ๐ŸŽฏ Pre-drag Delay - New preDragDelay prop for distinguishing taps from drags
  • ๐Ÿ“ npm Workspaces - Example app now uses workspace-based development setup
  • ๐Ÿ”ฒ Sortable Grids - 2D grid drag-and-drop with flexible layouts and insert/swap modes
  • โ†• Dynamic Heights - Sortable list support for variable item heights

๐ŸŽฏ Next Release

Focus: Enhanced Functionality & New Features

  • ๐Ÿ› Bug Fixes & Issues Resolution

    • Address existing reported issues
    • Performance optimizations
    • Gesture handling improvements
    • API Improvements
  • ๐Ÿช† Nested Sortable Lists

    • Multi-level hierarchy support
    • Collapse/expand functionality
    • Parent-child relationship management
    • Tree-like data structure handling
  • ๐Ÿ“‹ Kanban Board Support

    • Cross-list dragging capabilities
    • Multiple column support
    • Inter-list item transfer
    • Board-level state management

๐Ÿ’ก Community Requests

Vote on features you'd like to see by raising an issue.

Have an idea? Open a feature request and let me know!

๐Ÿค– AI Integration Skill

Speed up development with the official agent skill. It teaches AI coding agents (Claude Code, Codex, Cursor, Gemini CLI, Copilot, and 30+ more) the full API so they generate correct code โ€” no hallucinated props.

# Install via npx skills (auto-detects your agents)
npx skills add entropyconquers/react-native-reanimated-dnd

# Or install globally
npx skills add entropyconquers/react-native-reanimated-dnd -g

Once installed, just describe what you want:

"Add a sortable list where I can reorder items by dragging"

"Create a drag and drop interface with drop zones"

"Make a reorderable 3-column grid"

Your agent will generate complete, working implementations with correct imports, props, and state management.

The skill ships in both .claude/skills/ (Claude Code) and .agents/skills/ (Codex, Cursor, Gemini CLI, Copilot, and others) for universal agent compatibility. See the AI Integration Skill docs for all installation options and the full agent compatibility table.

๐Ÿค Contributing

Contributions are always welcome! We believe in building this library together with the community.

Ways to contribute:

  • ๐Ÿ› Report bugs and issues
  • โœจ Suggest new features
  • ๐Ÿ”ง Submit pull requests
  • ๐Ÿ“š Improve documentation
  • ๐Ÿงช Write tests
  • ๐Ÿ’ฌ Help others in discussions

Please see our Contributing Guide for detailed information on:

  • Setting up the development environment
  • Code style guidelines
  • Pull request process
  • Testing requirements
  • Community guidelines

๐Ÿ“„ License

MIT ยฉ Vishesh Raheja

๐Ÿ™ Acknowledgments

  • Built with React Native Reanimated for smooth 60fps animations
  • Gesture handling powered by React Native Gesture Handler
  • Inspired by the React ecosystem's drag-and-drop libraries
  • Special thanks to the React Native community for feedback and contributions

โ˜• Support the Project

If this library has helped you build amazing apps, consider supporting its development!

Buy Me a Coffee

Your support helps maintain and improve this library for the entire React Native community! ๐Ÿš€


Made with โค๏ธ for the React Native community

โญ Star on GitHub โ€ข ๐Ÿ“ฑ Try the Demo โ€ข ๐Ÿ“– Documentation

About

A powerful, performant drag-and-drop library for React Native built on Reanimated 4 and Gesture Handler. Smooth 60fps animations, sortable lists & grids, collision detection, and full TypeScript support.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages