Basic Zeroconf implementation for React-native
Get running services advertizing themselves using Zeroconf implementations like Avahi, Bonjour or NSD.
yarn add react-native-zeroconf # for react-native < 0.60 only (all platforms): react-native link # for ios (when using CocoaPods): (cd ios && pod install)
You can look at the wiki if you prefer a manual install.
TXT records will be available on iOS and Android >= 7.
For Android please ensure your manifest is requesting all necessary permissions.
Take a look at the example folder. Install the dependencies, run
node server.js and launch the project.
const zeroconf =
scan(type = 'http', protocol = 'tcp', domain = 'local.') Start the zeroconf scan
This will initialize the scan from the
Zeroconf instance. Will stop another scan if any is running.
stop() Stop the scan
If any scan is running, stop it. Otherwise do nothing.
getServices() Returns resolved services
Will return all names of services that have been resolved.
removeDeviceListeners() Remove listeners
Allow you to clean the listeners, avoiding potential memory leaks (#33).
addDeviceListeners() Add listeners
If you cleaned the listeners and need to get them back on.
publishService(type, protocol, domain, name, port) Publish a service
This adds a service for the current device to the discoverable services on the network.
domain should be the domain the service is sitting on, dot suffixed, for example
type should be both type and protocol, underscore prefixed, for example
name should be unique to the device, often the device name
port should be an integer
unpublishService(name) Unpublish a service
This removes a service from those discoverable on the network.
name should be the name used when publishing the service
start Triggered on scan start
stop Triggered on scan stop
found Triggered when a service is found
Broadcast a service name as soon as it is found.
resolved Triggered when a service is resolved
Broadcast a service object once it is fully resolved
remove Triggered when a service is removed
Broadcast a service name removed from the network.