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

bare-mdns-discovery

v0.2.3

Published

bare-mdns-discovery

Readme

bare-mdns-discovery

⚠️ Experimental Claude generated prototype

Minimal mDNS/DNS-SD service discovery.

Installation

npm install bare-mdns-discovery

Usage

Low-level mDNS queries

const { MDNS } = require('bare-mdns-discovery')

const mdns = new MDNS({ debug: true })
await mdns.ready()

mdns.on('records', (records, rinfo) => {
  console.log('from:', rinfo.address)
  for (const r of records) {
    console.log(r.type, r.name, r.data)
  }
})

mdns.query('_services._dns-sd._udp.local')
mdns.query('_http._tcp.local')
mdns.query('_googlecast._tcp.local')

setTimeout(() => mdns.close(), 10000)

Service discovery

const { Discovery } = require('bare-mdns-discovery')

const discovery = new Discovery({ service: 'googlecast' })
await discovery.ready()

discovery.on('service', (service) => {
  console.log('Found:', service.name, service.address, service.port)
})

const services = await discovery.discover(10) // 10 second timeout
console.log('All services:', services)

await discovery.close()

Extending for specific services

const { Discovery } = require('bare-mdns-discovery')

class MyServiceDiscovery extends Discovery {
  constructor(opts = {}) {
    super({ ...opts, service: 'myservice' })
  }

  _parseService(records, rinfo) {
    const service = super._parseService(records, rinfo)
    if (!service) return null

    // Add custom filtering or fields
    return {
      ...service,
      customField: service.txt.someKey
    }
  }
}

API

new MDNS(opts?)

Create a low-level mDNS instance.

Options:

  • debug (boolean): Enable debug logging. Default: false
  • iface (string): IPv4 address of the network interface to join the multicast group on. Required on Android — without this, addMembership falls back to the OS default interface which may not be the WiFi interface, causing responses to be silently dropped. Pass the WiFi IP (e.g. from bare-wifi-android's getWifiIP()).

mdns.ready()

Wait for the socket to be bound. Returns a Promise.

mdns.query(name, type?)

Send an mDNS query.

  • name (string): Service name, e.g. '_http._tcp.local'
  • type (number): Record type. Default: TYPE.PTR (12)

mdns.close()

Close the socket. Returns a Promise.

Event: 'records'

Emitted when records are received.

mdns.on('records', (records, rinfo) => {
  // records: Array of parsed DNS records
  // rinfo: { address, port, family, size }
})

new Discovery(opts?)

High-level service discovery. Extends MDNS.

Options:

  • service (string): Service type without prefix/suffix, e.g. 'http', 'googlecast'
  • debug (boolean): Enable debug logging. Default: false

discovery.discover(timeout?)

Discover services on the network. Returns a Promise resolving to an array of services.

  • timeout (number): Discovery timeout in seconds. Default: 10

discovery.services

Map of discovered services keyed by uid.

Event: 'service'

Emitted when a service is discovered.

discovery.on('service', (service) => {
  // service: { uid, name, address, addresses, port, target, txt }
})

Record Types

const { TYPE } = require('bare-mdns-discovery')

TYPE.A // 1 - IPv4 address
TYPE.PTR // 12 - Pointer
TYPE.TXT // 16 - Text
TYPE.AAAA // 28 - IPv6 address
TYPE.SRV // 33 - Service

Constants

const { MDNS_ADDR, MDNS_PORT } = require('bare-mdns-discovery')

MDNS_ADDR // '224.0.0.251'
MDNS_PORT // 5353

License

Apache-2.0