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

@fugood/dns-sd

v0.1.0-alpha.1

Published

Cross platform DNS-SD

Downloads

57

Readme

dns-sd

A powerful, cross-platform DNS-SD (Zeroconf/Bonjour/Avahi) library for Node.js, built with Rust.

dns-sd provides a unified API for discovering and advertising services on the local network. It intelligently selects the best available backend:

  • Native: Uses the system's native DNS-SD implementation (Avahi on Linux, Bonjour on macOS/Windows) for optimal performance and compatibility.
  • Fallback: Automatically degrades to a pure Rust implementation (mdns-sd) if the native service is unavailable.

Features

  • 🚀 High Performance: Native bindings via Neon for low overhead.
  • 🔄 Dual Backend: Robust fallback mechanism ensures your app works everywhere.
  • 📦 Zero Configuration: Works out of the box without complex setup.
  • 📡 Discovery & Advertising: Support for both browsing and publishing services.
  • 📝 TypeScript Support: First-class types included.

Installation

npm install dns-sd

Prebuilt binaries are available for major platforms:

  • Windows (x64, arm64)
  • macOS (x64, arm64)
  • Linux (x64, arm64)

Usage

Discover Services

Browsing for services is simple. Use the search method to start listening for services of a specific type.

import DnsSd, { Service } from 'dns-sd';

// Search for HTTP services
const browser = DnsSd.search('_http._tcp');

browser.on('serviceFound', (service: Service) => {
  console.log('Found service:', service.name);
  console.log('IP Addresses:', service.addresses);
  console.log('Port:', service.port);
  if (service.txt) {
    console.log('TXT Records:', service.txt);
  }
});

browser.on('serviceLost', (service: Service) => {
  console.log('Lost service:', service.name);
});

browser.on('error', (err) => {
  console.error('Browser error:', err);
});

// Stop browsing after 30 seconds
setTimeout(() => {
  browser.stop();
}, 30000);

Advertise a Service

Publish your own service to the network using advertise.

import DnsSd, { DnsSdAdvertisement } from 'dns-sd';

const ad = DnsSd.advertise({
  name: 'My Cool Service',
  type: '_http._tcp',
  port: 8080,
  txt: {
    version: '1.0.0',
    path: '/api'
  }
});

ad.on('registered', (name) => {
  console.log(`Service registered successfully as "${name}"`);
});

ad.on('error', (err) => {
  console.error('Advertisement error:', err);
});

// Stop advertising when closing
// ad.stop();

Check Backend

You can check which backend is currently active (dependent on system availability).

import DnsSd from 'dns-sd';

console.log('Current Backend:', DnsSd.getBackendInfo());
// Outputs: "bonjour", "native" (Avahi), or "mdns-sd"

API Reference

DnsSd

The main entry point.

  • static search(serviceType: string): DnsSdBrowse: Start a browser for the given service type (e.g., _http._tcp).
  • static advertise(options: AdvertiseOptions): DnsSdAdvertisement: Start advertising a service.
  • static getBackendInfo(): string: Returns the name of the active backend.

DnsSdBrowse

Emits events for service discovery.

Events:

  • 'serviceFound': Emitted when a service is discovered or updated. Payload: Service.
  • 'serviceLost': Emitted when a service goes offline. Payload: Service.
  • 'error': Emitted on failure. Payload: Error.

Methods:

  • stop(): Stops the browser.

DnsSdAdvertisement

Manages a published service.

Events:

  • 'registered': Emitted when the service is successfully registered with the daemon. Payload: string (registered name).
  • 'error': Emitted on failure. Payload: Error.

Methods:

  • stop(): Stops advertising.

Types

Service

interface Service {
  name: string;
  type: string;
  domain: string;
  hostName: string;
  addresses: string[]; // IPv4 and IPv6 addresses
  port: number;
  txt?: Record<string, string>;
  ttl?: number;
}

AdvertiseOptions

interface AdvertiseOptions {
  name: string;
  type: string;
  domain?: string;
  hostName?: string;
  port: number;
  txt?: Record<string, string>;
}

Contributing

This project uses cargo for the Rust backend and npm for the Node.js frontend.

  1. Install Dependencies: npm install
  2. Build: npm run build
  3. Test: npm test

Licensed under MIT.