Skip to main content

Migration Guide

How to migrate to Dropup from other popular upload libraries.

From react-dropzone

react-dropzone is a popular drag-and-drop library. Dropup provides similar functionality with built-in upload support.

Before (react-dropzone)

import { useDropzone } from 'react-dropzone';

function OldUploader() {
const [files, setFiles] = useState([]);

const { getRootProps, getInputProps, isDragActive } = useDropzone({
accept: { 'image/*': [] },
maxSize: 10485760,
onDrop: (acceptedFiles) => {
setFiles(acceptedFiles.map(file => ({
...file,
preview: URL.createObjectURL(file),
})));
},
});

const handleUpload = async () => {
for (const file of files) {
const formData = new FormData();
formData.append('file', file);
await fetch('/api/upload', {
method: 'POST',
body: formData,
});
}
};

return (
<div {...getRootProps()}>
<input {...getInputProps()} />
{isDragActive ? <p>Drop here</p> : <p>Drag files here</p>}
</div>
);
}

After (Dropup)

import { useDropup } from '@samithahansaka/dropup';

function NewUploader() {
const { files, actions, state, getDropProps, getInputProps } = useDropup({
accept: 'image/*',
maxSize: 10 * 1024 * 1024,
upload: { url: '/api/upload' }, // Built-in upload!
});

return (
<div {...getDropProps()}>
<input {...getInputProps()} />
{state.isDragging ? <p>Drop here</p> : <p>Drag files here</p>}

{files.map(file => (
<div key={file.id}>
{file.preview && <img src={file.preview} />}
<span>{file.progress}%</span>
</div>
))}

<button onClick={() => actions.upload()}>Upload</button>
</div>
);
}

Key Differences

react-dropzoneDropup
getRootProps()getDropProps()
isDragActivestate.isDragging
accept: { 'image/*': [] }accept: 'image/*'
No upload supportBuilt-in upload with progress
Manual preview cleanupAutomatic cleanup

From react-uploady

react-uploady is a feature-rich upload library with multiple components.

Before (react-uploady)

import Uploady, { useItemProgressListener, useUploady } from '@rpldy/uploady';
import UploadDropZone from '@rpldy/upload-drop-zone';

function OldApp() {
return (
<Uploady destination={{ url: '/api/upload' }}>
<UploadDropZone onDragOverClassName="drag-over">
<div>Drop files here</div>
</UploadDropZone>
<UploadProgress />
</Uploady>
);
}

function UploadProgress() {
useItemProgressListener((item) => {
console.log(`${item.file.name}: ${item.completed}%`);
});

const { processPending } = useUploady();

return <button onClick={processPending}>Upload</button>;
}

After (Dropup)

import { useDropup } from '@samithahansaka/dropup';

function NewApp() {
const { files, actions, getDropProps, getInputProps } = useDropup({
upload: { url: '/api/upload' },
onUploadProgress: (file, progress) => {
console.log(`${file.name}: ${progress}%`);
},
});

return (
<div {...getDropProps()}>
<input {...getInputProps()} />
<div>Drop files here</div>

{files.map(file => (
<div key={file.id}>
{file.name}: {file.progress}%
</div>
))}

<button onClick={() => actions.upload()}>Upload</button>
</div>
);
}

Key Differences

react-uploadyDropup
Provider + ComponentsSingle hook
useItemProgressListeneronUploadProgress callback
processPending()actions.upload()
Multiple packagesAll-in-one

From react-dropzone-uploader

react-dropzone-uploader combines dropzone with upload functionality.

Before (react-dropzone-uploader)

import Dropzone from 'react-dropzone-uploader';
import 'react-dropzone-uploader/dist/styles.css';

function OldUploader() {
const getUploadParams = () => ({ url: '/api/upload' });

const handleChangeStatus = ({ meta, file }, status) => {
console.log(status, meta, file);
};

return (
<Dropzone
getUploadParams={getUploadParams}
onChangeStatus={handleChangeStatus}
accept="image/*"
maxSizeBytes={10485760}
/>
);
}

After (Dropup)

import { useDropup } from '@samithahansaka/dropup';

function NewUploader() {
const { files, getDropProps, getInputProps } = useDropup({
accept: 'image/*',
maxSize: 10 * 1024 * 1024,
upload: { url: '/api/upload' },
autoUpload: true,

onUploadStart: (file) => console.log('uploading', file),
onUploadComplete: (file) => console.log('done', file),
onUploadError: (file, err) => console.log('error', file, err),
});

return (
<div {...getDropProps()}>
<input {...getInputProps()} />
{/* Your custom UI */}
</div>
);
}

Key Differences

react-dropzone-uploaderDropup
Component with built-in UIHeadless (bring your own UI)
getUploadParamsupload option
onChangeStatusSpecific callbacks
CSS import requiredNo styles

From Uppy

Uppy is a full-featured upload toolkit.

Before (Uppy)

import Uppy from '@uppy/core';
import Dashboard from '@uppy/dashboard';
import XHRUpload from '@uppy/xhr-upload';
import '@uppy/core/dist/style.css';
import '@uppy/dashboard/dist/style.css';

const uppy = new Uppy()
.use(Dashboard, { inline: true, target: '#uppy' })
.use(XHRUpload, { endpoint: '/api/upload' });

uppy.on('upload-success', (file, response) => {
console.log('Success:', file, response);
});

function OldUploader() {
return <div id="uppy" />;
}

After (Dropup)

import { useDropup } from '@samithahansaka/dropup';

function NewUploader() {
const { files, actions, state, getDropProps, getInputProps } = useDropup({
upload: { url: '/api/upload' },
onUploadComplete: (file, response) => {
console.log('Success:', file, response);
},
});

return (
<div>
<div {...getDropProps()}>
<input {...getInputProps()} />
Drop files here
</div>

{files.map(file => (
<div key={file.id}>
{file.preview && <img src={file.preview} />}
<span>{file.name}</span>
<span>{file.progress}%</span>
</div>
))}

<button onClick={() => actions.upload()}>Upload</button>
</div>
);
}

Key Differences

UppyDropup
Full UI includedHeadless
Plugin systemAll-in-one
Larger bundle< 10KB
Imperative APIReact hooks

Common Migration Steps

1. Install Dropup

npm uninstall react-dropzone react-uploady @rpldy/uploady  # Remove old
npm install @samithahansaka/dropup

2. Update Imports

// Before
import { useDropzone } from 'react-dropzone';

// After
import { useDropup } from '@samithahansaka/dropup';

3. Update Hook Usage

// Before
const { getRootProps, getInputProps, isDragActive } = useDropzone({...});

// After
const { getDropProps, getInputProps, state } = useDropup({...});
// Use state.isDragging instead of isDragActive

4. Add Upload Config

// Dropup includes upload functionality
useDropup({
upload: { url: '/api/upload' },
});

5. Update Event Handlers

// Before (react-dropzone)
onDrop: (files) => {...}

// After (Dropup)
onFilesAdded: (files) => {...}
onUploadComplete: (file) => {...}

6. Update Template

// Before
<div {...getRootProps()}>
<input {...getInputProps()} />
</div>

// After
<div {...getDropProps()}>
<input {...getInputProps()} />
</div>

Feature Comparison

Featurereact-dropzonereact-uploadyUppyDropup
Drag & Drop
Upload
Progress
Chunked
tus
Cloud (S3)
React Native
Bundle Size~10KB~30KB~100KB+<10KB
TypeScript
HeadlessPartial