WebTorrent The streaming torrent client. For node.js and the web. Sponsored by WebTorrent is a streaming torrent client for node.js and the browser. YEP, THAT'S RIGHT. THE BROWSER. It's written…
WebTorrent
The streaming torrent client. For node.js and the web.
Sponsored by
WebTorrent is a streaming torrent client for node.js and the browser. YEP,
THAT'S RIGHT. THE BROWSER. It's written completely in JavaScript – the language of the web
– so the same code works in both runtimes.
In node.js, this module is a simple torrent client, using TCP and UDP to talk to
other torrent clients.
In the browser, WebTorrent uses WebRTC (data channels) for peer-to-peer transport.
It can be used without browser plugins, extensions, or installations. It's Just
JavaScript™. Note: WebTorrent does not support UDP/TCP peers in browser.
Simply include thewebtorrent.min.js script
on your page to start fetching files over WebRTC using the BitTorrent protocol, orimport WebTorrent from 'webtorrent' with browserify or webpack. See [demo apps
](#who-is-using-webtorrent-today) and [code examples](#usage) below.

To make BitTorrent work over WebRTC (which is the only P2P transport that works on the
web) we made some protocol changes. Therefore, a browser-based WebTorrent client or "web
peer" can only connect to other clients that support WebTorrent/WebRTC.
To seed files to web peers, use a client that supports WebTorrent, e.g.
[WebTorrent Desktop][webtorrent-desktop], a desktop client with a
familiar UI that can connect to web peers,
webtorrent-hybrid, a command line program,
or Instant.io, a website. Established torrent clients like
Vuze have already added WebTorrent support so
they can connect to both normal *and* web peers. We hope other clients will follow.
Features
- Torrent client for node.js & the browser (same npm package!)
- Insanely fast
- Download multiple torrents simultaneously, efficiently
- Pure Javascript (no native dependencies)
- Exposes files as streams
- Supports advanced torrent client features
- Comprehensive test suite (runs completely offline, so it's reliable and fast)
- Check all the [supported BEPs here](docs/bep_support.md)
Browser/WebRTC environment features
- WebRTC data channels for lightweight peer-to-peer communication with no plugins
- No silos. WebTorrent is a P2P network for the entire web. WebTorrent clients
- Stream video torrents into a `
tag (webm, mkv, mp4, ogv, mov, etc (AV1, H264, HEVC*, VP8, VP9, AAC, FLAC, MP3, OPUS, Vorbis, etc)) - Supports Chrome, Firefox, Opera and Safari.
Install
To install WebTorrent for use in node or the browser with import WebTorrent from 'webtorrent', run:
bash
npm install webtorrent
To install a webtorrent
command line program, run:
bash
npm install webtorrent-cli -g
To install a WebTorrent desktop application for Mac, Windows, or Linux, see
[WebTorrent Desktop][webtorrent-desktop].
Ways to help
- Join us in [Gitter][webtorrent-gitter-url] or on freenode at #webtorrent
to help
- Create a new issue to report bugs
- Fix an issue. WebTorrent
Who is using WebTorrent today?
[Lots of folks!](docs/faq.md#who-is-using-webtorrent-today)
WebTorrent API Documentation
[Read the full API Documentation](docs/api.md).
Usage
WebTorrent is the first BitTorrent client that works in the browser, using open web
standards (no plugins, just HTML5 and WebRTC)! It's easy to get started!
In the browser
Downloading a file is simple:
js
import WebTorrent from 'webtorrent'
const client = new WebTorrent()
const magnetURI = '...'
client.add(magnetURI, torrent => {
// Got torrent metadata!
console.log('Client is downloading:', torrent.infoHash)
for (const file of torrent.files) {
document.body.append(file.name)
}
})
Seeding a file is simple, too:
js
import dragDrop from 'drag-drop'
import WebTorrent from 'webtorrent'
const client = new WebTorrent()
// When user drops files on the browser, create a new torrent and start seeding it!
dragDrop('body', files => {
client.seed(files, torrent => {
console.log('Client is seeding:', torrent.infoHash)
})
})
There are more examples in [docs/get-started.md](docs/get-started.md).
Browserify
WebTorrent works great with browserify, an npm package that lets
you use node-style require() to organize your browser code and load modules installed by npm (as seen in the previous examples).
Webpack
WebTorrent also works with webpack, another module
bundler. However, webpack requires extra configuration which you can find in [the webpack bundle config used by webtorrent](/scripts/browser.webpack.js).
Or, you can just use the pre-built version via
import WebTorrent from 'webtorrent/dist/webtorrent.min.js' and skip the webpack configuration.
Script tag
WebTorrent is also available as a standalone script
([webtorrent.min.js](webtorrent.min.js)) which exposes WebTorrent on the window
object, so it can be used with just a script tag:
html
import WebTorrent from 'webtorrent.min.js'
The WebTorrent script is also hosted on fast, reliable CDN infrastructure for easy inclusion on your site:
html
import WebTorrent from 'https://esm.sh/webtorrent/dist/webtorrent.min.js'
Chrome App
If you want to use WebTorrent in a
Chrome App, you can include the
following script:
html
import WebTorrent from 'webtorrent.chromeapp.js'
Be sure to enable the chrome.sockets.udp and chrome.sockets.tcp` permissions!
In Node.js
WebTorrent also works in node.js, using the *same npm package!* It's mad science!
NOTE: To connect to "web peers" (browsers) in addition to normal BitTorrent peers, use
webtorrent-hybrid which includes WebRTC
support for node.
As a command line app
WebTorrent is also available as a
command line app. Here's how to use it:
bash
$ npm install webtorrent-cli -g
$ webtorrent --help
To download a torrent:
bash
$ webtorrent magnet_uri
To stream a torrent to a device like AirPlay or Chromecast, just pass a flag:
bash
$ webtorrent magnet_uri --airplay
There are many supported streaming options:
bash
--airplay Apple TV
--chromecast Chromecast
--mplayer MPlayer
--mpv MPV
--omx [jack] omx [default: hdmi]
--vlc VLC
--xbmc XBMC
--stdout standard out [implies --quiet]
In addition to magnet uris, WebTorrent supports [many ways](docs/api.md#clientaddtorrentid-opts-function-ontorrent-torrent-) to specify a torrent.
Talks about WebTorrent
- Sep 2017 - Nordic JS - Get Rich Quick With P2P Crypto Currency
- May 2017 - Char.la - WebTorrent and Peerify (Spanish)
- Nov 2016 - NodeConf Argentina - Real world Electron: Building Cross-platform desktop apps with JavaScript
- May 2016 - SIGNAL Conference - BitTorrent in the Browser
- May 2015 - Data Terra Nemo - WebTorrent: Mother of all demos
- May 2015 - Data Terra Nemo - WebRTC Everywhere
- Nov 2014 - JSConf Asia - How WebTorrent Works
- Sep 2014 - NodeConf EU - WebRTC Mad Science (first working WebTorrent demo)
- Apr 2014 - CraftConf - Bringing BitTorrent to the Web
- May 2014 - JS.LA - How I Built a BitTorrent Client in the Browser (progress update; node client working)
- Oct 2013 - RealtimeConf - WebRTC Black Magic (first mention of idea for WebTorrent)
Modules
Most of the active development is happening inside of small npm packages which are used by WebTorrent.
The Node Way™
> "When applications are done well, they are just the really application-specific, brackish residue that can't be so easily abstracted away. All the nice, reusable components sublimate away onto github and npm where everybody can collaborate to advance the commons." — substack from "how I write modules"
Modules
These are the main modules that make up WebTorrent:
| module | tests | version | description |
|---|---|---|---|
| [webtorrent][webtorrent] | [![][webtorrent-ti]][webtorrent-tu] | [![][webtorrent-ni]][webtorrent-nu] | torrent client (this module)
| [bittorrent-dht][bittorrent-dht] | [![][bittorrent-dht-ti]][bittorrent-dht-tu] | [![][bittorrent-dht-ni]][bittorrent-dht-nu] | distributed hash table client
| [bittorrent-peerid][bittorrent-peerid] | [![][bittorrent-peerid-ti]][bittorrent-peerid-tu] | [![][bittorrent-peerid-ni]][bittorrent-peerid-nu] | identify client name/version
| [bittorrent-protocol][bittorrent-protocol] | [![][bittorrent-protocol-ti]][bittorrent-protocol-tu] | [![][bittorrent-protocol-ni]][bittorrent-protocol-nu] | bittorrent protocol stream
| [bittorrent-tracker][bittorrent-tracker] | [![][bittorrent-tracker-ti]][bittorrent-tracker-tu] | [![][bittorrent-tracker-ni]][bittorrent-tracker-nu] | bittorrent tracker server/client
| [bittorrent-lsd][bittorrent-lsd] | [![][bittorrent-lsd-ti]][bittorrent-lsd-tu] | [![][bittorrent-lsd-ni]][bittorrent-lsd-nu] | bittorrent local service discovery
| [create-torrent][create-torrent] | [![][create-torrent-ti]][create-torrent-tu] | [![][create-torrent-ni]][create-torrent-nu] | create .torrent files
| [magnet-uri][magnet-uri] | [![][magnet-uri-ti]][magnet-uri-tu] | [![][magnet-uri-ni]][magnet-uri-nu] | parse magnet uris
| [parse-torrent][parse-torrent] | [![][parse-torrent-ti]][parse-torrent-tu] | [![][parse-torrent-ni]][parse-torrent-nu] | parse torrent identifiers
| [torrent-discovery][torrent-discovery] | [![][torrent-discovery-ti]][torrent-discovery-tu] | [![][torrent-discovery-ni]][torrent-discovery-nu] | find peers via dht, tracker, and lsd
| [ut_metadata][ut_metadata] | [![][ut_metadata-ti]][ut_metadata-tu] | [![][ut_metadata-ni]][ut_metadata-nu] | metadata for magnet uris (protocol extension)
| [ut_pex][ut_pex] | [![][ut_pex-ti]][ut_pex-tu] | [![][ut_pex-ni]][ut_pex-nu] | peer discovery (protocol extension)
[webtorrent]: https://github.com/webtorrent/webtorrent
[webtorrent-gitter-url]: https://gitter.im/webtorrent/webtorrent
[webtorrent-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/webtorrent/ci.yml
[webtorrent-tu]: https://github.com/webtorrent/webtorrent/actions
[webtorrent-ni]: https://img.shields.io/npm/v/webtorrent.svg
[webtorrent-nu]: https://www.npmjs.com/package/webtorrent
[webtorrent-desktop]: https://webtorrent.io/desktop
[bittorrent-dht]: https://github.com/webtorrent/bittorrent-dht
[bittorrent-dht-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-dht/ci.yml?branch=master
[bittorrent-dht-tu]: https://github.com/webtorrent/bittorrent-dht/actions
[bittorrent-dht-ni]: https://img.shields.io/npm/v/bittorrent-dht.svg
[bittorrent-dht-nu]: https://www.npmjs.com/package/bittorrent-dht
[bittorrent-peerid]: https://github.com/webtorrent/bittorrent-peerid
[bittorrent-peerid-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-peerid/ci.yml?branch=master
[bittorrent-peerid-tu]: https://github.com/webtorrent/bittorrent-peerid/actions
[bittorrent-peerid-ni]: https://img.shields.io/npm/v/bittorrent-peerid.svg
[bittorrent-peerid-nu]: https://www.npmjs.com/package/bittorrent-peerid
[bittorrent-protocol]: https://github.com/webtorrent/bittorrent-protocol
[bittorrent-protocol-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-protocol/ci.yml?branch=master
[bittorrent-protocol-tu]: https://github.com/webtorrent/bittorrent-protocol/actions
[bittorrent-protocol-ni]: https://img.shields.io/npm/v/bittorrent-protocol.svg
[bittorrent-protocol-nu]: https://www.npmjs.com/package/bittorrent-protocol
[bittorrent-tracker]: https://github.com/webtorrent/bittorrent-tracker
[bittorrent-tracker-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-tracker/ci.yml?branch=master
[bittorrent-tracker-tu]: https://github.com/webtorrent/bittorrent-tracker/actions
[bittorrent-tracker-ni]: https://img.shields.io/npm/v/bittorrent-tracker.svg
[bittorrent-tracker-nu]: https://www.npmjs.com/package/bittorrent
…
Members
-
webtorrent ★ PINNED
⚡️ Streaming torrent client for the web
JavaScript ★ 31k 18h agoExplain → -
webtorrent-desktop ★ PINNED
❤️ Streaming torrent app for Mac, Windows, and Linux
JavaScript ★ 10k 1d agoExplain → -
webtorrent-cli ★ PINNED
WebTorrent, the streaming torrent client. For the command line.
JavaScript ★ 1.4k 1d agoExplain → -
instant.io ★ PINNED
🚀 Streaming file transfer over WebTorrent (torrents on the web)
JavaScript ★ 3.6k 1d agoExplain → -
bittorrent-dht ★ PINNED
🕸 Simple, robust, BitTorrent DHT implementation
JavaScript ★ 1.3k 11d agoExplain → -
bittorrent-tracker ★ PINNED
🌊 Simple, robust, BitTorrent tracker (client & server) implementation
JavaScript ★ 1.9k 1d agoExplain → -
wormhole-crypto
Streaming encryption for Wormhole.app, based on Encrypted Content-Encoding for HTTP (RFC 8188)
JavaScript ★ 699 6mo agoExplain → -
webtorrent-hybrid ▣
WebTorrent (with WebRTC support in Node.js)
JavaScript ★ 530 2mo agoExplain → -
parse-torrent
Parse a torrent identifier (magnet uri, .torrent file, info hash)
JavaScript ★ 463 3d agoExplain → -
bittorrent-protocol
Simple, robust, BitTorrent peer wire protocol implementation
JavaScript ★ 357 2d agoExplain → -
create-torrent
Create .torrent files
JavaScript ★ 356 1d agoExplain → -
magnet-uri
Parse a magnet URI and return an object of keys/values
JavaScript ★ 236 3d agoExplain → -
torrent-discovery
Discover BitTorrent and WebTorrent peers
JavaScript ★ 228 9d agoExplain → -
node-bencode
bencode de/encoder for nodejs
JavaScript ★ 173 9d agoExplain → -
webtorrent.io
The code that runs the WebTorrent website
JavaScript ★ 131 1d agoExplain → -
ut_metadata
BitTorrent Extension for Peers to Send Metadata Files (BEP 9)
JavaScript ★ 112 2d agoExplain → -
bittorrent-peerid
Map a BitTorrent peer ID to a human-readable client name and version
JavaScript ★ 71 9d agoExplain → -
ut_pex
Implementation of ut_pex bittorrent protocol (PEX) for webtorrent
JavaScript ★ 61 2d agoExplain → -
parse-torrent-file ▣
DEPRECATED: Parse a .torrent file and return an object of keys/values
JavaScript ★ 61 8y agoExplain → -
workshop
Learn WebTorrent and WebRTC in a guided workshop!
★ 51 2y agoExplain → -
bittorrent-lsd
Local Service Discovery (BEP14) implementation
JavaScript ★ 39 8d agoExplain → -
idb-chunk-store
IndexedDB chunk store that is abstract-chunk-store compliant
JavaScript ★ 36 1y agoExplain → -
fs-chunk-store
Filesystem (fs) chunk store that is abstract-chunk-store compliant
JavaScript ★ 35 9d agoExplain → -
torrent-piece
Torrent piece abstraction
JavaScript ★ 27 15d agoExplain → -
webtorrent-fixtures
Sample torrent files for the WebTorrent test suite
JavaScript ★ 25 9d agoExplain → -
load-ip-set
download and parse ip-set (blocklist) files
JavaScript ★ 24 9d agoExplain → -
fs-access-chunk-store
File System Access API chunk store that is abstract-chunk-store compliant
JavaScript ★ 19 15d agoExplain → -
lt_donthave
The BitTorrent lt_donthave extension (BEP 54)
JavaScript ★ 13 2d agoExplain → -
addr-to-ip-port
Convert an "address:port" string to an array [address:string, port:number]
JavaScript ★ 12 9d agoExplain → -
bep53-range
Parse and compose Magnet URI extension (BEP53) ranges
JavaScript ★ 10 9d agoExplain → -
string2compact
Convert 'hostname:port' strings to BitTorrent's compact ip/host binary returned by Trackers
JavaScript ★ 9 9d agoExplain → -
http-node ⑂
Node.js http as a standalone package
JavaScript ★ 5 3y agoExplain → -
airplayer ⑂
Query your local network for Apple TV's and have them play videos
JavaScript ★ 5 3y agoExplain → -
multicast-dns ⑂
Low level multicast-dns implementation in pure javascript
JavaScript ★ 4 3y agoExplain → -
airplay-protocol ⑂
A low level protocol wrapper on top of the AirPlay HTTP API
★ 3 3y agoExplain → -
semantic-release-config
No description.
JavaScript ★ 1 8d agoExplain → -
.github
No description.
★ 1 1y agoExplain → -
renovate-config
Renovate's config
★ 1 2y agoExplain →
No repos match these filters.