Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsMay 28, 2026·3 min de lectura

React DnD — Drag and Drop for React Applications

A set of React utilities for building complex drag-and-drop interfaces while keeping components decoupled.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
React DnD Overview
Comando de instalación directa
npx -y tokrepo@latest install 14dd9b81-5a2a-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

React DnD is a drag-and-drop library for React built on a flexible backend architecture. Rather than wrapping the DOM drag-and-drop API directly, it exposes a set of hooks and higher-order components that let you describe drag sources and drop targets declaratively.

What React DnD Does

  • Provides useDrag and useDrop hooks for declarative drag-and-drop logic
  • Supports swappable backends (HTML5, Touch, custom)
  • Enables complex interactions like sortable lists, kanban boards, and file drops
  • Handles drag previews, custom layers, and snapping behavior
  • Works with React's concurrent rendering and strict mode

Architecture Overview

React DnD uses a monitor-based architecture inspired by Flux. A central DnD manager tracks drag state, while backends translate platform events into internal actions. Components subscribe to state changes through hooks, and the library reconciles updates efficiently without re-rendering the entire tree.

Self-Hosting & Configuration

  • Install the core package and at least one backend (HTML5 or Touch)
  • Wrap your app in <DndProvider backend={...}> at the root level
  • Configure drag preview images using the preview connector
  • Use useDragLayer for custom floating drag layers
  • Combine with react-dnd-multi-backend for simultaneous mouse and touch support

Key Features

  • Hook-based API that integrates cleanly with modern React patterns
  • Backend-agnostic design allows testing without a real DOM
  • Built-in support for nested drop targets with priority resolution
  • Drag preview customization via custom render layers
  • TypeScript support with full generic type parameters

Comparison with Similar Tools

  • dnd-kit — Newer alternative with simpler API; React DnD is more mature with broader community adoption
  • react-beautiful-dnd — Opinionated and specialized for vertical/horizontal list reordering; React DnD is more general
  • SortableJS — Framework-agnostic but less idiomatic in React; React DnD is designed for React
  • Pragmatic drag and drop — Atlassian's lightweight approach; React DnD offers more built-in abstractions

FAQ

Q: Does React DnD support touch devices? A: Yes. Use the react-dnd-touch-backend package alongside or instead of the HTML5 backend.

Q: Can I use it with Next.js or SSR? A: Yes, but the HTML5 backend requires a browser environment. Use dynamic imports or conditional rendering for SSR.

Q: How does it compare to the native HTML5 drag-and-drop API? A: React DnD wraps the native API via backends and adds state management, type matching, and preview handling that the raw API lacks.

Q: Is it still actively maintained? A: The project receives community contributions and remains widely used in production across many large codebases.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados