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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@inthepocket/react-native-service-discovery

v0.2.4

Published

mDNS Network Service Discovery in React Native

Readme

🌍 mDNS Network Service Discovery in React Native

npm License: MIT

This library allows you to discover services on your local network using mDNS (DNS-SD, Bonjour, Zeroconf, Avahi, ...). Devices that support service discovery include printers, webcams, HTTPS servers, and other mobile devices. The library uses NSNetServiceBrowser on iOS and NsdManager on Android.

Installation

npm install @inthepocket/react-native-service-discovery

Add the services you want to search for in Info.plist:

<key>NSBonjourServices</key>
<array>
  <!-- Change to your services -->
  <string>_ssh._tcp</string> 
  <string>_http._tcp</string>
</array>

Add a custom Local Network prompt message in Info.plist:

<key>NSLocalNetworkUsageDescription</key>
<string>${PRODUCT_NAME} uses the local network to discover and connect to devices on your Wi-Fi network.</string>

Usage

import * as ServiceDiscovery from '@inthepocket/react-native-service-discovery';

const foundListener = ServiceDiscovery.addEventListener('serviceFound', (service) => {
  console.log('Service found:', service);
});

const lostListener = ServiceDiscovery.addEventListener('serviceLost', (service) => {
  console.log('Service lost:', service);
});

// Start searching for _http._tcp. services
await ServiceDiscovery.startSearch('http');

// ...
await ServiceDiscovery.stopSearch('http');
foundListener.remove();
lostListener.remove();

startSearch

Start searching for services of a specific type. Searching for multiple services can be done in parallel.

| Parameter | Type | Description | | --------- | ------ | ----------- | | type | string | The service type to search for, e.g. 'http'. The device will search for services of type _serviceType._tcp.. |

Returns

Promise<void> - Resolves when the search has started. Rejects when the search could not be started.

stopSearch

Stop searching for a specific service. This will not stop searching for any other services that are being searched for.

| Parameter | Type | Description | | --------- | ------ | ----------- | | type | string | The service type to stop searching for, e.g. 'http'. |

Returns

Promise<void> - Resolves when the search has stopped. Rejects when the search could not be stopped. Does not reject when the search was already stopped or was not started in the first place.

addEventListener

| Parameter | Type | Description | | --------- | ------ | ----------- | | event | 'serviceFound' \| 'serviceLost' | Start listening for found or lost services. | | listener | (service: Service) => void | The listener that will be called when a service is found or lost. |

Returns

An EmitterSubscription that can be used to remove the listener, by calling remove().

Service

| Attribute | Type | Description | | --------- | ------ | ----------- | | name | string | Service name. | | type | string | Service type, e.g. _http._tcp.. | | domain | string | Domain, can be local. or any other domain. | | hostName | string | The domain name of the IP advertising the service. On local networks this is usually the host name. | | addresses | string[] | The IP addresses of the service. This is an array of IPv4 and IPv6 addresses. | | port | number | The port number where the service can be reached. | | txt | Record<string, string> | The TXT record of the service. The TXT record gives additional information about the service. |

Listening for multiple service types

You can listen for multiple service types with the same listener:

import * as ServiceDiscovery from '@inthepocket/react-native-service-discovery';

ServiceDiscovery.addEventListener('serviceFound', (service) => {
  if(service.type === '_http._tcp.') {
    console.log('HTTP service found:', service);
  } else if(service.type === '_ssh._tcp.') {
    console.log('SSH service found:', service);
  }
});

await ServiceDiscovery.startSearch('http');
await ServiceDiscovery.startSearch('ssh');

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Many thanks to