Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rpldy/react-uploady
Modern file uploading - components & hooks for React
https://github.com/rpldy/react-uploady
browser chunked-uploads components drag-and-drop file-upload file-uploader files hooks javascript react react-native reactjs resumable resumable-upload ssr upload
Last synced: 2 days ago
JSON representation
Modern file uploading - components & hooks for React
- Host: GitHub
- URL: https://github.com/rpldy/react-uploady
- Owner: rpldy
- License: mit
- Created: 2019-11-12T09:29:05.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-01T20:51:37.000Z (2 months ago)
- Last Synced: 2024-10-29T15:34:32.381Z (about 1 month ago)
- Topics: browser, chunked-uploads, components, drag-and-drop, file-upload, file-uploader, files, hooks, javascript, react, react-native, reactjs, resumable, resumable-upload, ssr, upload
- Language: JavaScript
- Homepage: https://react-uploady.org/
- Size: 29.2 MB
- Stars: 1,108
- Watchers: 8
- Forks: 36
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-react-cn - react-uploady - Modern file-upload components & hooks for React. (Uncategorized / Uncategorized)
- awesome-learning-resources - react-uploady - Modern file-upload components & hooks for React. (Uncategorized / Uncategorized)
- best-of-react - GitHub - 0% open ยท โฑ๏ธ 02.06.2024): (File Handling)
- awesome-react - react-uploady - Modern file uploading - components & hooks for React ` ๐ 10 days ago` (React [๐](#readme))
- awesome-react - react-uploady - Modern file-upload components & hooks for React (**Awesome React** [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) / React)
README
![React Uploady Logo](https://github.com/rpldy/react-uploady-docs/blob/master/static/img/uploady/react-uploady-text-logo-light.png#gh-dark-mode-only)
![React Uploady Logo](https://github.com/rpldy/react-uploady-docs/blob/master/static/img/uploady/react-uploady-text-logo.png#gh-light-mode-only)Modern file-upload components & hooks for React.
Contents
* [Intro](#intro)
* [Documentation](#documentation)
* [Installation](#installation)
* [Packages](#packages)
* [Examples](#examples)
* [Important Concepts](#important-concepts)
* [Resumable Uploads](#resumable-uploads)
* [UMD Bundles](#umd-bundles)
* [Contribute](#contribute)
* [Acknowledgements](#acknowledgements)## Intro
React-Uploady is a lightweight library - enabling you to build (client-side) file-upload features with just a few lines of code.
Uploady provides the foundations needed to upload files from the browser - The rest is up to you.![React-Uploady Demo](guides/rpldy-demo.gif)
The philosophy behind this library is that it should be as simple as possible to use, yet customizable at every point.
You can start simple, or you can configure just about every aspect of the upload flow.
For this purpose, there are components, hooks, and plenty of features.
You get to choose which ones you need and only install the dependencies required (See [Packages](#packages) details below)React-Uploady has a small footprint (by design) with very few (tiny) dependencies.
| Bundle | Minified size | GZipped size |
|-----------------------------|---------------|--------------|
| core | 29.1KB | 10.5KB |
| core + ui | 36.9KB | 13.3KB |
| core + ui + chunked support | 44.1KB | 15.7KB |
| everything | 71.0KB | 22.9KB |## Documentation
### Getting Started
**The best place to get started is at our: [React-Uploady Documentation Website](https://react-uploady.org)**
Another great place to learn about React-Uploady is our [video series on Youtube](https://youtube.com/playlist?list=PLigk9hpU4jsqZM7Fr3DxThJ--hsFWG8xk).
### Changelog
For a list of versions and changes, see the [CHANGELOG](CHANGELOG.md)
### Discussions
Please check the [discussions area](https://github.com/rpldy/react-uploady/discussions) here in Github. If you have a question about use-cases or flows you'd like to achieve with Uploady, discussions is the place to look for existing answers or add your own.
If you're using Uploady in Production, please drop a comment [here](https://github.com/rpldy/react-uploady/discussions/131). It's always great to hear how people and companies use it.
## Installation
React-uploady is a mono-repo, and as such provides multiple packages with different functionality.
For React applications, at the very least, you will need the Uploady provider:
```shell
#Yarn:
$ yarn add @rpldy/uploady#NPM:
$ npm i @rpldy/uploady
```If you wish to use the uploading mechanism (no UI), at the very least, you will need the Uploader:
```shell
#Yarn:
$ yarn add @rpldy/uploader#NPM:
$ npm i @rpldy/uploader
```After that, you can add additional packages as needed. See below for more details.
## Packages
### Main Packages
* [@rpldy/uploader](packages/core/uploader) - The processing and queuing engine
* [@rpldy/uploady](packages/ui/uploady) - The context provider for react-uploady and hooks (lots of hooks)### UI Packages
* [@rpldy/upload-button](packages/ui/upload-button) - Upload button component and asUploadButton HOC
* [@rpldy/upload-preview](packages/ui/upload-preview) - Image&video preview component for files being uploaded
* [@rpldy/upload-url-input](packages/ui/upload-url-input) - Input component to send URL as upload info (ex: [Cloudinary](https://cloudinary.com/documentation/upload_images#auto_fetching_remote_images))
* [@rpldy/upload-drop-zone](packages/ui/upload-drop-zone) - (Drag&)Drop zone to upload files and folder content
* [@rpldy/upload-paste](packages/ui/upload-paste) - Easily add paste-to-upload to React components
* [@rpldy/retry-hooks](packages/ui/retry-hooks) - Hooks to interact with the retry mechanism### Providers
* [@rpldy/chunked-uploady](packages/ui/chunked-uploady) - Wrapper for Uploady with support for chunked uploads
* [@rpldy/tus-uploady](packages/ui/tus-uploady) - Wrapper for Uploady with support for tus(resumable) uploads
* [@rpldy/native-uploady](packages/native/native-uploady) - Uploady for React Native (no react-dom)### Senders
* [@rpldy/sender](packages/core/sender) - Uploady's main file sender (XHR)
* [@rpldy/chunked-sender](packages/core/chunked-sender) - add chunked uploads support on top of the XHR Sender
* [@rpldy/tus-sender](packages/core/tus-sender) - add TUS resumable upload support
* [@rpldy/mock-sender](packages/core/mock-sender) - use Mock sender for testing purposes### Extras
* [@rpldy/retry](packages/core/retry) - Add support for retrying failed uploads### Internal Packages
* [@rpldy/shared](packages/core/shared) - Internal set of utils+types that all packages require
* [@rpldy/shared-ui](packages/ui/shared) - Internal set of utils+types that all UI packages require
* [@rpldy/life-events](packages/core/life-events) - provides **cancellable** pub/sub "events"
* [@rpldy/safe-storage](packages/core/safe-storage) - safe (don't throw) versions of local and session storage
* [@rpldy/simple-state](packages/core/simple-state) - deep proxy object, so it's only updateable through an update method## Examples
For specific usage, see documentation in the relevant package README file.
For upload options, see the [@rpldy/uploady docs](https://react-uploady.org/docs/api/#props).
### Simple Upload Button
This example shows how you add Uploady and UploadButton to your app.
This is all it takes to get file uploading to work in your React application.```javascript
import React from "react";
import Uploady from "@rpldy/uploady";
import UploadButton from "@rpldy/upload-button";const App = () => (
);```
### Custom Upload Button
In case you want to use your own component as the upload trigger, use the asUploadButton HOC:
```javascript
import React from "react";
import Uploady from "@rpldy/uploady";
import { asUploadButton } from "@rpldy/upload-button";const DivUploadButton = asUploadButton((props) => {
return
DIV Upload Button
});const App = () => (
);```
### Progress Hook
```javascript
import React from "react";
import Uploady, { useItemProgressListener } from "@rpldy/uploady";
import UploadButton from "@rpldy/upload-button";//must be rendered inside
const LogProgress = () => {
useItemProgressListener((item) => {
console.log(`>>>>> (hook) File ${item.file.name} completed: ${item.completed}`);
});return null;
}const App = () => (
);```
### Add support for resumable(tus) uploads```javascript
import React from "react";
import TusUploady from "@rpldy/tus-uploady";
import UploadButton from "@rpldy/upload-button";
const App = () => (
);
```### Add support for chunked uploads
Can be used with servers that support chunked uploads
```javascript
import React from "react";
import ChunkedUploady from "@rpldy/chunked-uploady";
import UploadButton from "@rpldy/upload-button";const App = () => (
);```
> Find more (advanced) examples in our [guides](https://react-uploady.org/docs/guides/) and [storybook](https://react-uploady-storybook.netlify.com/).
## Important Concepts
### Upload Options
These are the options that are passed to the [uploader](https://react-uploady.org/docs/api/uploader/#upload-options) to configure aspects of the upload process.
For example, whether files can be grouped in a single request (by default, no).Upload Options are typically passed to the [Uploady](https://react-uploady.org/docs/api/#props) instance. But these can be overridden. For example, by props passed to the [upload button](https://react-uploady.org/docs/api/components/uploadButton/#props).
Or even during [upload processing](https://react-uploady.org/docs/guides/DynamicParameters/).### Destination
Passed as a part of the upload options. It's an object that is used to configure the end-point where the files will be uploaded to.
Its type is defined [here](https://react-uploady.org/docs/api/types/#destination).See more information in the [Uploady](https://react-uploady.org/docs/api/) doc.
At the very least, a destination should contain a URL property with the server endpoint.
### Enhancer
```javascript
(uploader: UploaderType, trigger: Trigger) => UploaderType
```Enhancers are functions that can enhance an uploader instance. They are also passed as part of the options given to the Uploady instance.
As they are applied when the uploader instance is created, they can change the way uploader does things or pass different defaults.
See this [guide](https://react-uploady.org/docs/guides/UploaderEnhancers/) for practical information and sample code.
### Batch
When a file or files are handed over to the uploader, they are grouped into a batch.
This batch will have its own lifetime [events](https://react-uploady.org/docs/api/events/).
With a batch ID, it is possible to cancel all files that are part of it. It can also be used to retry all files in the batch (see [@rpldy/retry](https://react-uploady.org/docs/packages/rpldy-retry/)).### BatchItem
Each file (or URL) added to the uploader is wrapped by a BatchItem object. They will have a unique ID within the life-time of the uploader instance.
A BatchItem has its own lifetime [events](https://react-uploady.org/docs/api/events/).## Resumable Uploads
Uploady supports resumable uploads through the [tus](https://tus.io/) [protocol](https://tus.io/protocols/resumable-upload.html).
Instead of using <Uploady> from @rpldy/uploady, use <TusUploady> from @rpldy/tus-uploady and you will have resumable upload support on the client side.
Your server will also have to support the same protocol for this to work, of course.See the [@rpldy/tus-uploady](https://react-uploady.org/docs/packages/rpldy-tus-uploady/) documentation for more details.
## UMD Bundles
React-uploady is also available on CDNs such as [unpkg.com](https://unpkg.com) and [jsdelivr.com](https://www.jsdelivr.com/)
See this [guide](guides/UMD.md) for more information on how to use.
### jsDelivr
| Bundle | URL |
|-----------------------------|----------------------------------------------------------------------------------------------|
| core | https://cdn.jsdelivr.net/npm/@rpldy/uploader/lib/umd/rpldy-core.umd.min.js |
| core + ui | https://cdn.jsdelivr.net/npm/@rpldy/uploady/lib/umd/rpldy-ui-core.umd.min.js |
| core + ui + chunked support | https://cdn.jsdelivr.net/npm/@rpldy/chunked-uploady/lib/umd/rpldy-ui-core-chunked.umd.min.js |
| everything | https://cdn.jsdelivr.net/npm/@rpldy/uploady/lib/umd/rpldy-all.umd.min.js |You will most likely need the polyfill (core js) bundle as well (load it first):
- core bundles -> https://cdn.jsdelivr.net/npm/@rpldy/uploady/lib/umd/polyfills-bundle.js
- everything bundle -> https://cdn.jsdelivr.net/npm/@rpldy/uploady/lib/umd/polyfills-all-bundle.js### unpkg
| Bundle | URL |
|-----------------------------|-----------------------------------------------------------------------------------|
| core | https://unpkg.com/@rpldy/uploader/lib/umd/rpldy-core.umd.min.js |
| core + ui | https://unpkg.com/@rpldy/uploady/lib/umd/rpldy-ui-core.umd.min.js |
| core + ui + chunked support | https://unpkg.com/@rpldy/chunked-uploady/lib/umd/rpldy-ui-core-chunked.umd.min.js |
| everything | https://unpkg.com/@rpldy/uploady/lib/umd/rpldy-all.umd.min.js |You will most likely need the polyfill (core js) bundle as well (load it first):
- core bundles -> https://unpkg.com/@rpldy/uploady/lib/umd/polyfills-bundle.js
- everything bundle -> https://unpkg.com/@rpldy/uploady/lib/umd/polyfills-all-bundle.js> Note that unpkg does a redirect to the latest version in case the URL doesn't already contain it. So don't copy any of the URLs above into your code.
> Instead, load them in the browser first and then copy the final URL from there (after the redirect).## Contribute
Show Uploady your support by giving us a [โญ](https://github.com/rpldy/react-uploady/stargazers).
If you'd like to help Uploady grow & improve, take a look at the [Contributing](CONTRIBUTING.md) doc.
The [Discussions](https://github.com/rpldy/react-uploady/discussions) page is a great place to ask questions, raise ideas and interact with Uploady maintainer, users and contributors.
Already using Uploady in Production? Let us know how & where in this open [discussion](https://github.com/rpldy/react-uploady/discussions/131).
### Financial Contributors
Companies/Organizations that have contributed to the project:
#### Support us
Want to help sustain and grow Uploady? You can become a financial backer on OpenCollective.
Become a financial contributor and help us sustain our community.
> You can make a one-time contribution or on a monthly basis
Or just [buy me a coffee](https://www.buymeacoffee.com/yoav) ๐
## Acknowledgements
logo's wing thanks to Illustration Vectors by Vecteezy