Skip to content

WebTorrent

A torrent client for Node.js and the browser that can stream video while it downloads.

Stars
31.5k
Forks
2.9k
Licence
MIT
Language
JavaScript
Last update
5 days ago
Type
Library

What it is

WebTorrent is a BitTorrent client written entirely in JavaScript that runs in both Node.js and web browsers. It lets a program fetch files from torrents and expose them as streams, so video can start playing before the download finishes. In browsers it uses WebRTC so no plugins or extensions are needed, though browser peers can only connect to other WebTorrent-capable clients.

  • Stream a video torrent into an HTML video tag while it is still downloading
  • Seed files from a browser by dragging them onto a page and sharing a magnet link
  • Download a torrent from a magnet URI in a Node.js script
  • Use the webtorrent command line program (installed separately) to fetch torrents

Great for

  • Developers who want to add torrent downloading or streaming to a JavaScript web or Node.js app
  • Web projects that need peer-to-peer file transfer without installing browser plugins
  • Teams building in-browser video streaming from torrents
  • Developers who want a pure JavaScript BitTorrent implementation with no native dependencies

Not ideal for

  • People who just want a ready-made torrent app to download files; the README points to WebTorrent Desktop for that and this repo is a library
  • Users who need browser peers to talk to standard UDP/TCP-only torrent clients, since the README says browsers cannot reach those peers directly
  • Projects needing a stable, fully documented API for production without reviewing the docs themselves, as the README only links to external API docs
Step-by-step guide: how to use WebTorrentInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js

    Install the library from npm

    npm install webtorrent

    Install the command line program globally

    npm install webtorrent-cli -g
  2. 2

    Run it

    • Install the webtorrent package with npm in your project
    • Create a client with new WebTorrent()
    • Call client.add() with a magnet URI or torrent file
    • In the callback, access torrent.files and use the file streams
  3. 3

    Get the most out of it

    • Use the streaming support to play video into a <video> tag before the download completes, per the README
    • Read docs/get-started.md for more examples and docs/api.md for the full API
    • Check docs/bep_support.md to see which BitTorrent Enhancement Proposals are supported
    • Use the protocol extension API to add custom extensions
    • Use the prebuilt webtorrent.min.js from the CDN to skip webpack configuration

Downloads

Strengths

  • Same npm package works in Node.js and the browser
  • Pure JavaScript with no native dependencies, and the README says the test suite runs offline
  • Supports streaming with seeking, fetching pieces on demand

Trade-offs

  • Browser peers can only connect to other WebTorrent/WebRTC clients, not standard torrent clients directly
  • Webpack needs extra configuration unless you use the prebuilt bundle
  • Latest release is listed without binaries, so use via npm or source

How it compares

ProjectStarsTypeLevelUpdatedBest for
webtorrent (this)31.5kLibraryintermediate5 days agoDevelopers who want to add torrent downloading or streaming to a JavaScript web or Node.js app
webtorrent-desktop10.1kAppbeginner6 days agoPeople who want to stream torrent video without waiting for a full download
peerjs13.5kLibraryintermediate8 months agoWeb developers adding real-time chat or file-style data exchange between browsers
srs29.4kAppintermediate6 days agoDevelopers building live streaming backends that need several delivery protocols
go2rtc14.6kAppintermediate11 days agoHome users connecting IP cameras to a browser or Home Assistant
monaco-editor46.9kLibraryintermediate6 days agoWeb developers adding a code editing box to a browser app

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.