# bittorrent-lsd

> Local Service Discovery (BEP14) implementation

Latest version **2.0.3** (published 2026-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install bittorrent-lsd
pnpm add bittorrent-lsd
yarn add bittorrent-lsd
bun add bittorrent-lsd
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2026-05-25 |
| First published | 2020-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12.20.0 |
| Dependencies | 2 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 39 |
| Author | WebTorrent LLC |
| Maintainers | feross, mafintosh, flet, watson, diegorbaquero, hicom150, jhiesey, webtorrent-bot, alxhotel |
| Keywords | bittorrent, bep14, lsd, local service discovery, protocol, peer, p2p, peer-to-peer, webtorrent |

## Links

- npm: https://www.npmjs.com/package/bittorrent-lsd
- Repository: https://github.com/webtorrent/bittorrent-lsd
- Homepage: https://github.com/webtorrent/bittorrent-lsd#readme
- Issues: https://github.com/webtorrent/bittorrent-lsd/issues
- Funding: https://github.com/sponsors/feross
- npm.io page: https://npm.io/package/bittorrent-lsd

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.2.0
- [chrome-dgram](https://npm.io/package/chrome-dgram.md) ^3.0.6

## Recent versions

- 2.0.3 (latest) — 2026-05-25
- 2.0.2 — 2026-05-25
- 2.0.0 — 2022-12-05
- 1.1.1 — 2021-07-22
- 1.1.0 — 2020-11-12
- 1.0.1 — 2020-11-10
- 1.0.0 — 2020-11-04

## README

# bittorrent-lsd [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]

[ci-image]: https://github.com/webtorrent/bittorrent-lsd/actions/workflows/ci.yml/badge.svg?branch=master
[ci-url]: https://github.com/webtorrent/bittorrent-lsd/actions/workflows/ci.yml
[npm-image]: https://img.shields.io/npm/v/bittorrent-lsd.svg
[npm-url]: https://npmjs.org/package/bittorrent-lsd
[downloads-image]: https://img.shields.io/npm/dm/bittorrent-lsd.svg
[downloads-url]: https://npmjs.org/package/bittorrent-lsd
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com

### Local Service Discovery (BEP14) implementation.

Local Service Discovery (LSD) provides a SSDP-like (http over udp-multicast) mechanism to announce the presence in specific swarms to local neighbors.

This module is used by [WebTorrent](http://webtorrent.io).

## install

```
npm install bittorrent-lsd
```

## example

```
const opts = {
  peerId: new Buffer('01234567890123456789'), // hex string or Buffer
  infoHash: new Buffer('01234567890123456789'), // hex string or Buffer
  port: common.randomPort() // torrent client port
}

const lsd = new LSD(opts)

// start getting peers from local network
lsd.start()

lsd.on('peer', (peerAddress, infoHash) => {
  console.log('found a peer: ' + peerAddress)
})

lsd.destroy()
```

## api

### `lsd = new LSD([opts])`
Create a new `lsd` instance.

### `lsd.start()`
Start listening and sending (every 5 minutes) for local network announces.

### `lsd.destroy([callback])`
Destroy the LSD. Closes the socket and cleans up resources.

## events

### `lsd.on('peer', (peerAddress, infoHash) => { ... })`
Emitted when a potential peer is found. `peerAddress` is of the form `host:port`. `infoHash` is the torrent info hash.

### `lsd.on('warning', (err) => { ... })`
Emitted when the LSD gets an unexpected message.

### `lsd.on('error', (err) => { ... })`
Emitted when the LSD has a fatal error.

## license

MIT. Copyright (c) [Julen Garcia Leunda](https://github.com/hicom150) and [WebTorrent, LLC](https://webtorrent.io).

---
_Source: https://npm.io/package/bittorrent-lsd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
