react-dropzone

A lightweight React hook for building HTML5-compliant drag-and-drop file upload zones.

Library
npm
v20.1.0
11,013stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
90/100Excellent
Development Activity96
Maintenance96
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture85
Code Quality88
Innovation82
Learning Curve90

react-dropzone is a small, dependency-light React hook (useDropzone) that turns any element into an HTML5-compliant drag-and-drop file upload zone. It handles the native drag/drop and file-picker plumbing — accepted/rejected file lists, MIME-type and extension filtering, size limits, multi-file support, and keyboard accessibility — and exposes prop-getter functions (getRootProps, getInputProps) so consumers can style the drop target however they like without fighting the library’s DOM.

It has been the de-facto standard for file uploads in the React ecosystem for years, with over 10,000 apps depending on it in production. The library ships as ESM and CommonJS with first-class TypeScript types, has zero runtime dependencies beyond two small internal packages (attr-accept, file-selector), and works with any modern bundler.

What You Get

  • A useDropzone hook that returns getRootProps()/getInputProps() prop-getter functions to wire drag-and-drop and click-to-browse onto any element you render
  • Built-in file validation: accept (MIME type/extension filtering), minSize/maxSize, maxFiles, and a pluggable validator function for custom rules
  • Granular drag-state booleans (isDragActive, isDragAccept, isDragReject, isDragUnknown, isFocused) for building responsive visual feedback
  • Keyboard and focus accessibility out of the box, including noKeyboard/noClick/noDrag escape hatches for custom interaction models
  • First-class TypeScript types and an optional File System Access API mode (useFsAccessApi) for richer native file pickers where supported

Common Use Cases

  • Adding a drag-and-drop upload zone to a form that then hands accepted files off to your own upload/HTTP logic
  • Building an image or media uploader with client-side type/size validation before hitting an API
  • Multi-file batch upload UIs (e.g. document management, CMS asset panels) with per-file rejection reasons surfaced to the user
  • Accessible file-picker components where both drag-and-drop and keyboard/click flows must work identically

Under The Hood

Architecture The useDropzone hook holds all interaction state in a single useReducer (isFocused, isDragActive/Accept/Reject/Unknown, acceptedFiles, fileRejections). Drag/drop event handlers call getFilesFromEvent (defaulting to file-selector’s fromEvent) to normalize native DataTransfer/FileList/FileSystemFileHandle inputs into a Promise<File[]>, then validate each file via fileAccepted/fileMatchSize/a custom validator before splitting results into acceptedFiles vs fileRejections and firing onDrop/onDropAccepted/onDropRejected. Root-scoped drag handlers compute a local accept/reject verdict via getDragVerdict, while separate document-level dragenter/dragleave/dragend/drop listeners (attached once via useEffect) track a global drag flag and prevent the browser’s default “open file in new tab” behavior for drops that land outside the configured zone. getRootProps/getInputProps are composeEventHandlers-based prop-getters that merge caller-supplied handlers with internal ones without clobbering either, and forwardRef exposes an imperative open() to trigger the hidden <input type="file"> programmatically.

Tech Stack TypeScript source (src/index.tsx ~840 lines, src/utils/index.ts ~430 lines) is bundled with tsdown into dual ESM/CJS output plus generated .d.ts types. Runtime dependencies are minimal — just attr-accept (MIME/extension matching) and file-selector (normalizing native file events) — with react >=18 as a peer dependency and @types/react optional. The dev toolchain is modern: oxlint/oxfmt for lint/format, Vitest + @testing-library/react + jsdom for tests, vocs for the documentation site, and semantic-release wired for automated npm/GitHub releases from conventional commits.

Code Quality The test suite (src/index.spec.tsx) runs to roughly 4,000 lines, covering drag/drop/paste event simulation, keyboard interaction, validator edge cases, and File System Access API branches, backed by snapshot tests; src/utils/index.spec.ts separately unit-tests the pure helper functions. Code is consistently typed with explicit interfaces (DropzoneOptions, DropzoneState, FileRejection, Accept, FileError) rather than loose any usage, and inline comments document non-obvious browser-compatibility workarounds with links to the originating GitHub issues. The pretest:cov script gates coverage runs behind type-check, lint, and format-check, indicating quality gates are enforced in CI rather than left informal.

API Design Returning prop-getter functions instead of pre-rendered markup is a deliberate, well-executed tradeoff: it costs a small amount of boilerplate ({...getRootProps()} / {...getInputProps()}) in exchange for consumers keeping full control over DOM structure and styling, and the getters correctly compose caller-supplied event handlers with internal ones instead of silently overwriting them. Defaults are sensible enough that a bare useDropzone({onDrop}) call produces a working zone, and escape hatches (noClick, noKeyboard, noDrag, noDragEventsBubbling) are provided for documented edge cases (e.g. <label> double-opening the file dialog) rather than leaving consumers to work around them unaided. Documentation is strong throughout — the README covers installation, both hook and wrapper-component usage, refs, testing patterns, and a dedicated “Caveats” section enumerating known browser quirks.

Used by 55 apps in this directory

Python
86%
MIT

ai-toolkit

AI Development · AI Design Tools

11,757

An all-in-one open-source training suite for finetuning diffusion models—FLUX, SDXL, Wan video, and audio—on consumer GPU hardware via CLI or web UI.

View details
77
Repo Health
66
Technical
75
Dependency
Built with
Python86%
TypeScript13%
Updated 2 days ago
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,010

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

10,880

A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.

View details
83
Repo Health
69
Technical
65
Dependency
Built with
TypeScript92%
Updated 2 weeks ago
JavaScript
99%
Other

ChartBrew

Analytics · Databases

4,041

Open-source reporting platform to build live dashboards from SQL, NoSQL, APIs, and SaaS tools with an AI assistant that creates charts from natural language.

View details
90
Repo Health
83
Technical
65
Dependency
Built with
JavaScript99%
Updated 6 days ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
Java
48%
Apache 2.0

ClearFlask

Product Management · Community

448

Open-source feedback management and roadmap tool that lets product teams collect, prioritize, and respond to user input — with AI-powered summarization and full self-hosting control.

View details
83
Repo Health
73
Technical
63
Dependency
Built with
Java48%
TypeScript47%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search