Skip to main content
WebTorrent implements a comprehensive set of BitTorrent Enhancement Proposals (BEPs) that define the protocols and extensions used in modern BitTorrent clients. Support varies between Node.js and browser environments due to platform limitations.

Understanding BEP Support

BitTorrent Enhancement Proposals (BEPs) are the standardized specifications that extend and improve the BitTorrent protocol. WebTorrent implements many of these proposals, with some differences between Node.js and browser environments.
Browser implementations are limited by web platform capabilities. Features requiring UDP/TCP sockets or system-level networking are only available in Node.js.

Core Protocol Support

BEP 5: Distributed Hash Table (DHT)

Status: ✅ Node.js | ❌ Browser BEP 5 defines the distributed hash table for decentralized peer discovery.
import WebTorrent from 'webtorrent'

// Enable DHT in Node.js (enabled by default)
const client = new WebTorrent({
  dht: true, // or pass DHT options object
  nodeId: '...', // optional DHT node ID
  dhtPort: 6881 // optional DHT port
})

// Access DHT instance
client.dht.on('listening', () => {
  console.log('DHT listening on port:', client.dht.address().port)
})
DHT is not available in browser environments due to UDP socket requirements. Browsers rely on WebRTC trackers and PEX for peer discovery.

BEP 6: Fast Extension

Status: ✅ Node.js | ✅ Browser BEP 6 adds fast peer rejection and “have all/none” messages to improve performance. This extension is automatically enabled and handles:
  • HAVE_ALL and HAVE_NONE messages
  • SUGGEST_PIECE messages
  • REJECT_REQUEST messages
  • ALLOWED_FAST messages
No configuration required - WebTorrent handles this automatically. Status: ✅ Node.js | ✅ Browser BEP 9 enables downloading torrents using magnet URIs without .torrent files.
const magnetURI = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10'

client.add(magnetURI, torrent => {
  console.log('Downloading:', torrent.name)
  console.log('InfoHash:', torrent.infoHash)
})

BEP 10: Extension Protocol

Status: ✅ Node.js | ✅ Browser BEP 10 provides the framework for protocol extensions, enabling features like metadata exchange and peer exchange. See the Extensions documentation for details on creating custom extensions.

Peer Discovery

BEP 11: Peer Exchange (PEX)

Status: ✅ Node.js | ⚠️ Browser (partial) BEP 11 enables peers to exchange peer lists, improving swarm connectivity.
// Enable or disable PEX
const client = new WebTorrent({
  utPex: true // enabled by default in Node.js
})
PEX in browsers is partially implemented. While the protocol works, browser peers can only exchange WebRTC peer information, not TCP/UDP peers. See issue #1191.

BEP 14: Local Service Discovery (LSD)

Status: ✅ Node.js | ❌ Browser BEP 14 discovers peers on the local network using UDP multicast.
// Enable LSD in Node.js (enabled by default)
const client = new WebTorrent({
  lsd: true
})
LSD cannot be implemented in browsers due to lack of multicast UDP support.

BEP 15: UDP Tracker Protocol

Status: ✅ Node.js | ❌ Browser BEP 15 defines the UDP tracker protocol for efficient tracker communication. Automatically used in Node.js when torrents have UDP tracker URLs (udp://...).

Web Seeds and HTTP

BEP 19: WebSeed - HTTP/FTP Seeding

Status: ✅ Node.js | ✅ Browser BEP 19 allows downloading from HTTP/FTP servers alongside peer-to-peer transfers.
// Enable web seeds (enabled by default)
const client = new WebTorrent({
  webSeeds: true
})

// Add custom web seeds when creating torrent
client.seed(files, {
  urlList: [
    'https://example.com/files/',
    'https://mirror.com/content/'
  ]
}, torrent => {
  console.log('Seeding with web seeds')
})
Configure maximum concurrent web seed connections per torrent:
client.add(magnetURI, {
  maxWebConns: 4 // default is 4
})

Tracker Extensions

BEP 23: Tracker Returns Compact Peer Lists

Status: ✅ Node.js | ⚠️ Not implemented BEP 23 enables trackers to return peer lists in compact binary format. Supported in Node.js for efficient peer list parsing.

BEP 48: Tracker Protocol Extension: Scrape

Status: ✅ Node.js | ✅ Browser BEP 48 allows querying tracker statistics without announcing. Automatically used when available.

Privacy and Security

BEP 27: Private Torrents

Status: ✅ Node.js | ✅ Browser BEP 27 prevents DHT and PEX sharing for private tracker torrents.
// Torrent files with 'private: 1' flag automatically enforce privacy
// You can also manually override:
client.add(torrentId, {
  private: true // disable DHT and PEX for this torrent
})
Private torrents will not be announced to the DHT or shared via PEX. Only tracker announces will occur.

Transport Protocol

BEP 29: uTorrent Transport Protocol (uTP)

Status: ✅ Node.js | ❌ Browser BEP 29 defines the uTP protocol for congestion control and NAT traversal.
import WebTorrent from 'webtorrent'

// Check if uTP is supported (requires utp-native)
console.log('uTP support:', WebTorrent.UTP_SUPPORT)

// Enable/disable uTP (enabled by default if available)
const client = new WebTorrent({
  utp: true
})
uTP support requires the optional utp-native dependency. Install with: npm install utp-native

Advanced Features

BEP 53: Magnet URI Extension - Select Specific Files

Status: ✅ Node.js | ✅ Browser BEP 53 enables selective file downloads using magnet links.
// Download only specific file indices
const magnet = 'magnet:?xt=urn:btih:...&so=0,2,4'

client.add(magnet, torrent => {
  // Files 0, 2, and 4 will be downloaded
  // Other files will be deselected
})

// Or select files programmatically
torrent.deselect(0, torrent.pieces.length - 1, false)
torrent.files.forEach((file, index) => {
  if (index === 0 || index === 2 || index === 4) {
    file.select()
  }
})

Not Yet Implemented

The following BEPs are not currently implemented but may be added in the future:
BEP 7 - IPv6 support for tracker communication.Status: Planned
BEP 32 - IPv6 support in the DHT.Status: Planned - See issue #88
BEP 44 - Store mutable and immutable data in the DHT.Status: Under consideration
BEP 46 - Dynamic torrent updates using DHT.Status: Planned - See issue #886
BEP 52 - Next generation BitTorrent protocol with improved hashing.Status: Planned - See issue #1117

Platform Comparison

BEPFeatureNode.jsBrowser
5DHT
6Fast Extension
9Magnet Links
10Extension Protocol
11Peer Exchange (PEX)⚠️
14Local Service Discovery
15UDP Tracker
19WebSeeds
23Compact Peer Lists
27Private Torrents
29uTP Protocol
48Tracker Scrape
53Selective Downloads
Legend:
  • ✅ Fully supported
  • ⚠️ Partially supported or limited
  • ❌ Not supported (platform limitation)

Next Steps

Protocol Extensions

Learn how to create custom protocol extensions

Performance

Optimize your WebTorrent implementation