Skip to content
Balthazar edited this page Oct 4, 2026 · 4 revisions

Contributing

Bug reports and pull requests are welcome on GitHub.

Repository layout

Path Contents
src/index.js JavaScript API (compiled to dist/ with Babel)
index.d.ts TypeScript definitions, keep in sync with src/index.js
ios/RNZeroconf/ iOS, macOS and tvOS module (Objective-C, dns_sd)
windows/RNZeroconf/ Windows module (C++): ZeroconfCore on windns.h, RNZeroconf bridges it to React Native
react-native-zeroconf.podspec CocoaPods spec
android/src/main/java/com/balthazargronon/RCTZeroconf/ Android module (nsd/ and dnssd/ implementations)
android/src/main/java/com/github/druk/dnssd/ Bundled DNS-SD Java API, from RxDNSSD
android/src/main/jni/ Embedded mDNSResponder, built with ndkBuild
example/ Expo example app, a network browser
test/ Jest tests (*.test.js), TypeScript checks (types/) and the iOS harness (ios/)
docs/, website/ This documentation and the website built from it

JavaScript

yarn install
yarn lint      # ESLint on src/
yarn format    # Prettier on src/
yarn build     # Babel: src/ -> dist/

Example app

A network browser built with Expo: it lists the devices on the network, grouped by host, with their services, addresses and TXT records. On Android it discovers the service types on the network with useServiceTypes. On iOS that requires the multicast entitlement, so it scans the types declared in app.json.

It runs against the library in this checkout (Metro resolves react-native-zeroconf to ../src), so changes to the JavaScript need no build. It needs a development build, not Expo Go:

cd example
npm install
npm run android   # or: npm run ios

android/ and ios/ are generated by expo prebuild and not committed. After changing native code, rebuild the app (npm run android / npm run ios), and run npx expo prebuild --clean when native files are added or removed.

Android

The Android module compiles the embedded mDNSResponder with the NDK, so the NDK must be installed (the module defaults to ndkVersion 27.1.12297006 unless the app overrides it through rootProject.ext.ndkVersion).

cd example/android
./gradlew assembleDebug

Testing

yarn test          # Jest: the JavaScript API against a mocked native module
yarn typecheck     # index.d.ts against the samples in test/types
test/ios/run.sh    # macOS: the iOS implementation with AddressSanitizer, against the local mDNSResponder
test\windows\run.cmd  # Windows: the Windows implementation (windows/RNZeroconf/ZeroconfCore.cpp) with Visual Studio's C++ tools

CI runs these on every pull request, and builds the example app for Android and iOS against the packed library. On Windows it also runs a second mDNS stack (test/windows/peer.py, python-zeroconf) for the harness to discover, and builds and launches a react-native-windows app running test/windows/App.tsx against it.

The Android module's instrumented tests (android/src/androidTest) drive the embedded mDNSResponder (implType: 'DNSSD') from several threads on a device or emulator, through the example app's Gradle project. They are not run in CI; run them for changes to the module's native code or to com.github.druk.dnssd:

cd example && npm ci && npx expo prebuild --platform android --no-install
adb shell setprop debug.checkjni 1   # JNI misuse then aborts with a clear message
cd android && ./gradlew :react-native-zeroconf:connectedDebugAndroidTest

A failure is often the test process crashing: look for the tombstone with adb logcat -b crash.

For changes to native code, also test on devices:

  • The Android emulator only sees services published inside it: publish test services from the app, or use a real device to discover real ones (Android Emulator).
  • On iOS, test on a device or simulator with Local Network access, and add the service types you test to the example's NSBonjourServices.
  • Useful tools on a Mac: dns-sd -B _http._tcp to browse, dns-sd -R "Test" _http._tcp local 8080 path=/ to publish a test service.
  • For Android changes, test both implType: 'NSD' and 'DNSSD', and if possible Android 14+ and an older version (the NSD code paths differ).

Documentation

The documentation lives in docs/ as Markdown. It is published at zeroconf.balthazar.dev and copied to the GitHub wiki as a backup.

  • Preview the site: python3 website/build.py docs website/dist/index.html, then open website/dist/index.html through any static server.
  • Deploy the site: website/deploy.sh (needs access to the cluster).
  • Update the wiki backup: website/sync-wiki.sh.

Pull requests

  • Keep README.md, index.d.ts and docs/ consistent with API changes.
  • Describe the platforms and OS versions you tested on.

Clone this wiki locally