npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@z-torrent/browser

v0.0.14

Published

Z-Torrent browser build — WebRTC, Service Worker, Web API bindings

Downloads

999

Readme

@z-torrent/browser

Browser build of Z-Torrent — WebRTC, Service Worker, Web API bindings.

Use this package for browser/SPA projects. For Node.js, use @z-torrent/node.

Install

npm install @z-torrent/browser
# optional, for WebRTC in environments that need it:
npm install webrtc-polyfill

Bundler-friendly entry (default)

The main export (@z-torrent/browser) is unbundled ESM: dependencies such as @z-torrent/core, @z-torrent/tracker, and @thaunknown/simple-peer stay external so your bundler (Vite, Webpack, etc.) can tree-shake and dedupe. Configure Node polyfills in your bundler where needed (e.g. vite-plugin-node-polyfills).

import { ZTorrent } from '@z-torrent/browser'

const client = new ZTorrent()

Types: dist/index.d.ts. For full client/torrent typings, depend on @z-torrent/core as well.

Standalone pre-bundled build

For CDN, a plain <script type="module">, or any setup without a bundler, use the standalone subpath (self-contained, minified):

import { ZTorrent } from '@z-torrent/browser/standalone'

This maps to dist/z-torrent.min.js and includes browser polyfills for transitive Node APIs.

Service worker

Streaming and createServer require a service worker registered at a URL under your site origin (browsers do not load workers from bare node_modules URLs).

Vite / Astro

Use the helper plugin from @z-torrent/browser/vite:

import { zTorrentSW } from '@z-torrent/browser/vite'

export default defineConfig({
  vite: {
    plugins: [zTorrentSW()],
  },
})

By default it serves and emits sw.min.js at the site root. Register it with:

const reg = await navigator.serviceWorker.register('/sw.min.js', { scope: '/' })
await navigator.serviceWorker.ready
client.createServer({ controller: reg })

Optional: zTorrentSW({ fileName: 'z-torrent-sw.js' }) if you need a different filename.

Without Vite

Copy node_modules/@z-torrent/browser/dist/sw.min.js into your static/public directory, or resolve the file via the package export @z-torrent/browser/sw and copy it in your build script.

MIME and <video>

Playback in <video> needs a correct Content-Type on the service worker response. Built-in overrides include Matroska (e.g. .mkvvideo/x-matroska); see @z-torrent/utils/streaming-mime.

Example (full flow)

import { ZTorrent } from '@z-torrent/browser'

const client = new ZTorrent()

const reg = await navigator.serviceWorker.register('/sw.min.js', { scope: '/' })
await navigator.serviceWorker.ready
client.createServer({ controller: reg })

client.add(magnetUri, (torrent) => {
  const file = torrent.files.find((f) => f.name.endsWith('.mp4'))
  file?.streamTo(videoElement)
})

Scripts

  • bun run build — bundler entry (index.js), standalone (z-torrent.min.js), service worker (sw.min.js), Vite plugin (vite-plugin.js)
  • bun run typechecktsc --noEmit
  • bun test — public API tests (run after build)