In node.js, this module is a simple torrent client, using TCP and UDP to talk to other torrent clients.
Simply include the
on your page to start fetching files over WebRTC using the BitTorrent protocol, or
require('webtorrent') with browserify. See demo apps
and code examples 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, 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.
webm (vp8, vp9)or
To install WebTorrent for use in node or the browser with
npm install webtorrent
To install a
command line program, run:
npm install webtorrent-cli -g
To install a WebTorrent desktop application for Mac, Windows, or Linux, see WebTorrent Desktop.
#webtorrentto help with development or to hang out with some mad science hackers :)
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!
var WebTorrent =var client =var magnetURI = '...'client
var dragDrop =var WebTorrent =var client =// When user drops files on the browser, create a new torrent and start seeding it!
There are more examples in docs/get-started.md.
WebTorrent also works with webpack, a module bundler similar to browserify. However, webpack requires the following extra configuration:
target: 'web'node:fs: 'empty'
If you are on webpack 1.x, you will also need to add the
module:loaders:// make sure to install the 'json-loader' package: npm install json-loadertest: /\.json$/loader: 'json'
Otherwise you could also directly use the pre-built version via
WebTorrent is also available as a standalone script
webtorrent.min.js) which exposes
WebTorrent on the
object, so it can be used with just a script tag:
The WebTorrent script is also hosted on fast, reliable CDN infrastructure (Cloudflare and MaxCDN) for easy inclusion on your site:
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.
WebTorrent is also available as a command line app. Here's how to use it:
$ npm install webtorrent-cli -g$ webtorrent --help
To download a torrent:
$ webtorrent magnet_uri
To stream a torrent to a device like AirPlay or Chromecast, just pass a flag:
$ webtorrent magnet_uri --airplay
There are many supported streaming options:
--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 to specify a torrent.
Most of the active development is happening inside of small npm packages which are used by WebTorrent.
"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"
These are the main modules that make up WebTorrent:
|webtorrent||torrent client (this module)|
|bittorrent-dht||distributed hash table client|
|bittorrent-peerid||identify client name/version|
|bittorrent-protocol||bittorrent protocol stream|
|bittorrent-tracker||bittorrent tracker server/client|
|create-torrent||create .torrent files|
|magnet-uri||parse magnet uris|
|parse-torrent||parse torrent identifiers|
|render-media||intelligently render media files|
|torrent-discovery||find peers via dht and tracker|
|ut_metadata||metadata for magnet uris (protocol extension)|
|ut_pex||peer discovery (protocol extension)|
In node, enable debug logs by setting the
DEBUG environment variable to the name of the
module you want to debug (e.g.
* to print all logs).
In the browser, enable debug logs by running this in the developer console:
localStoragedebug = '*'
Disable by running this: