# tus-js-client

> A pure JavaScript client for the tus resumable upload protocol

Latest version **4.3.1** (published 2025-01-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install tus-js-client
pnpm add tus-js-client
yarn add tus-js-client
bun add tus-js-client
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.3.1 |
| Published | 2025-01-16 |
| First published | 2015-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 7 |
| Unpacked size | 2.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2621 |
| Maintainers | acconut, tus-bot |
| Keywords | tus, resumable, upload, protocol, progress, file, browser |

## Links

- npm: https://www.npmjs.com/package/tus-js-client
- Repository: https://github.com/tus/tus-js-client
- Issues: https://github.com/tus/tus-js-client/issues
- npm.io page: https://npm.io/package/tus-js-client

## Dependencies (7)

- [is-stream](https://npm.io/package/is-stream.md) ^2.0.0
- [js-base64](https://npm.io/package/js-base64.md) ^3.7.2
- [url-parse](https://npm.io/package/url-parse.md) ^1.5.7
- [buffer-from](https://npm.io/package/buffer-from.md) ^1.1.2
- [combine-errors](https://npm.io/package/combine-errors.md) ^3.0.3
- [lodash.throttle](https://npm.io/package/lodash.throttle.md) ^4.1.1
- [proper-lockfile](https://npm.io/package/proper-lockfile.md) ^4.1.2

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 4.3.1 (latest) — 2025-01-16
- 5.0.0-pre2 (next) — 2026-01-13
- 5.0.0-pre1 — 2025-01-17
- 4.3.0 — 2025-01-14
- 4.2.3 — 2024-09-11
- 4.2.2 — 2024-09-11
- 4.2.1 — 2024-09-10
- 4.2.0 — 2024-09-09
- 4.1.0 — 2024-03-19
- 4.0.1 — 2023-12-22
- 4.0.0 — 2023-12-08
- 3.1.3 — 2023-12-08
- 3.1.2 — 2023-12-07
- 3.1.1 — 2023-08-02
- 3.1.0 — 2023-02-09
- … 39 more at https://npm.io/package/tus-js-client/versions

## README

# tus-js-client

<img alt="Tus logo" src="https://raw.githubusercontent.com/tus/tus.io/main/public/images/tus1.png?raw=true" width="30%" align="right" />

> **tus** is a protocol based on HTTP for _resumable file uploads_. Resumable
> means that an upload can be interrupted at any moment and can be resumed without
> re-uploading the previous data again. An interruption may happen willingly, if
> the user wants to pause, or by accident in case of an network issue or server
> outage.

tus-js-client is a pure **JavaScript** client for the [tus resumable upload protocol](http://tus.io) and can be used inside **browsers**, **Node.js**,
**React Native** and **Apache Cordova** applications.

**Protocol version:** 1.0.0

This branch contains tus-js-client v4. If you are looking for the previous major release, after which [breaking changes](https://github.com/tus/tus-js-client/releases/tag/v4.0.0) have been introduced, please look at the [v3.1.3 tag](https://github.com/tus/tus-js-client/tree/v3.1.3).

## Example

```js
input.addEventListener('change', function (e) {
  // Get the selected file from the input element
  var file = e.target.files[0]

  // Create a new tus upload
  var upload = new tus.Upload(file, {
    endpoint: 'http://localhost:1080/files/',
    retryDelays: [0, 3000, 5000, 10000, 20000],
    metadata: {
      filename: file.name,
      filetype: file.type,
    },
    onError: function (error) {
      console.log('Failed because: ' + error)
    },
    onProgress: function (bytesUploaded, bytesTotal) {
      var percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2)
      console.log(bytesUploaded, bytesTotal, percentage + '%')
    },
    onSuccess: function () {
      console.log('Download %s from %s', upload.file.name, upload.url)
    },
  })

  // Check if there are any previous uploads to continue.
  upload.findPreviousUploads().then(function (previousUploads) {
    // Found previous uploads so we select the first one.
    if (previousUploads.length) {
      upload.resumeFromPreviousUpload(previousUploads[0])
    }

    // Start the upload
    upload.start()
  })
})
```

## Documentation

- [Installation & Requirements](/docs/installation.md)
- [Usage & Examples](/docs/usage.md)
- [API Reference](/docs/api.md)
- [Contribution Guidelines](/docs/contributing.md)
- [FAQ & Common issues](/docs/faq.md)

## Build status

[![Actions Status](https://github.com/tus/tus-js-client/workflows/CI/badge.svg)](https://github.com/tus/tus-js-client/actions)

## License

This project is licensed under the MIT license, see `LICENSE`.

---
_Source: https://npm.io/package/tus-js-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
