SpawnDev.WebTorrent.Server 1.0.0

dotnet add package SpawnDev.WebTorrent.Server --version 1.0.0
                    
NuGet\Install-Package SpawnDev.WebTorrent.Server -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SpawnDev.WebTorrent.Server" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SpawnDev.WebTorrent.Server" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SpawnDev.WebTorrent.Server" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SpawnDev.WebTorrent.Server --version 1.0.0
                    
#r "nuget: SpawnDev.WebTorrent.Server, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SpawnDev.WebTorrent.Server@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SpawnDev.WebTorrent.Server&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SpawnDev.WebTorrent.Server&version=1.0.0
                    
Install as a Cake Tool

SpawnDev.WebTorrent

NuGet License: MIT

Pure C# BitTorrent/WebTorrent client and server. No JavaScript dependencies. Runs on desktop (.NET) and browser (Blazor WASM).

Features

  • Pure C# — No JavaScript interop, no Node.js, no npm. 100% .NET.
  • Desktop + Browser — Same library runs on .NET console/desktop apps and Blazor WebAssembly.
  • Random-Access Streaming — Read any byte range from a torrent file as it downloads. Perfect for ML model weight streaming.
  • WebSocket Tracker — Full tracker implementation with WebRTC signaling relay for browser peers.
  • Web Seed Support — HTTP range request fallback (BEP 17/19) when peers aren't available.
  • HuggingFace Integration — Optional server extension that proxies HuggingFace model CDN with local caching and automatic torrent generation.
  • .torrent Creation — Create and parse .torrent files. Complete Bencode encoder/decoder.

Packages

Package Description
SpawnDev.WebTorrent Client library — torrents, peers, streaming
SpawnDev.WebTorrent.Server Server library — tracker, web seed

Quick Start — Client

using SpawnDev.WebTorrent;

var client = new WebTorrentClient();
var torrent = await client.AddAsync("magnet:?xt=urn:btih:...");

// Stream a file as it downloads
var file = torrent.Files[0];
var chunk = await file.ReadAsync(offset: 0, length: 65536);

Quick Start — Server

using SpawnDev.WebTorrent.Server;

var tracker = new TorrentTracker();
var webSeed = new WebSeedServer("seed-data");

var app = WebApplication.CreateBuilder(args).Build();
app.UseWebSockets();
app.MapWebTorrentServer(tracker, webSeed);
app.Run();

Quick Start — HuggingFace Proxy

using SpawnDev.WebTorrent.Server.HuggingFace;

var proxy = new HuggingFaceProxy(new HuggingFaceProxyOptions
{
    CacheDirectory = "hf-cache",
});
app.MapHuggingFaceProxy(proxy);

// Clients access: https://your-server/hf/{repoId}/{filePath}
// Auto-caches from HuggingFace CDN on first request
// Generates .torrent files for P2P distribution

Why This Exists

AI models are big. CDNs can't scale when every user downloads the same 2GB model. SpawnDev.WebTorrent turns every browser into a peer — the more users, the faster delivery. Built for SpawnDev.ILGPU.ML, the GPU-accelerated ML library for Blazor WebAssembly.

Architecture

Browser Client                    Server (spawndev.com)
┌─────────────┐                  ┌──────────────────────┐
│ WebTorrent   │◄──WebSocket───►│ TorrentTracker       │
│ Client       │  (signaling)   │ (peer discovery)     │
│              │                │                      │
│ WebRTC ◄────►│ WebRTC         │ WebSeedServer        │
│ (P2P data)   │                │ (HTTP range fallback)│
│              │                │                      │
│ OPFS Cache   │                │ HuggingFaceProxy     │
│ (persistent) │                │ (fetch + cache + seed)│
└─────────────┘                  └──────────────────────┘
         ▲                                ▲
         │ P2P piece exchange             │ First fetch
         ▼                                ▼
┌─────────────┐                  ┌──────────────────────┐
│ Other        │                 │ HuggingFace CDN      │
│ Browser Peers│                 │ (origin source)      │
└─────────────┘                  └──────────────────────┘

Credits

Built by Todd Tanner (@LostBeard) and the SpawnDev team.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 34 3/27/2026