A dictionary of named flag constants for use with HSNetworkReachability.status().
Compare individual bits against these constants to determine which network conditions apply.
The numeric values match the deprecated SCNetworkReachabilityFlags for backward compatibility.
Returns all network interfaces present on this system.
Each object contains name (string), isLoopback (boolean), isUp (boolean), and isRunning (boolean). A displayName string is included when the system provides a human-readable label for the interface (e.g. "Wi-Fi" or "Ethernet").
Declaration
hs.network.interfaces() -> [[String: Any]]
Returns
[[String: Any]]
An array of objects describing each network interface.
The hostname to resolve (e.g. "example.com" or "localhost").
family
string
The address family to query: "ipv4" for A records only, "ipv6" for AAAA records only, or "both" to return all addresses. Defaults to "both" when omitted.
Returns
Promise<string[]>
A Promise that resolves to an array of IP address strings, or rejects with an error message if the lookup fails.
Creates a reachability monitor for a specific IP address.
Returns null if address is not a valid IPv4 or IPv6 address literal.
Under the hood this monitors general system connectivity (the same as reachabilityInternet()),
because NWPathMonitor does not support per-address targeting.
Creates a reachability monitor for a source/destination IP address pair.
Returns null if either address is not a valid IPv4 or IPv6 address literal.
Under the hood this monitors general system connectivity (the same as reachabilityInternet()),
because NWPathMonitor does not support per-address targeting.
Creates a reachability monitor for a given hostname.
Returns null if hostName is empty.
Under the hood this monitors general system connectivity (the same as reachabilityInternet()),
because NWPathMonitor does not support per-hostname targeting.
Creates a reachability monitor for link-local connectivity.
Link-local addresses cover the 169.254.x.x (IPv4) and fe80::/10 (IPv6) ranges
used for direct device-to-device communication without a router.
Under the hood this monitors general system connectivity (the same as reachabilityInternet()),
because NWPathMonitor does not distinguish link-local reachability.
Returns the contents of the macOS System Configuration dynamic store as a dictionary.
The store holds live network configuration for the running system — interface addresses,
routing, DNS servers, proxy settings, VPN state, and more. Keys follow a hierarchical
path convention (e.g. "State:/Network/Global/IPv4").
An optional regular expression that filters which keys are included.
Returns
{[key: string]: any}
A dictionary mapping key strings to their current values. Values may be
Example
// Dump everything
console.log(JSON.stringify(hs.network.configurationStore()))
// Filter to network state
const state = hs.network.configurationStore("State:/Network/.*")
console.log(state["State:/Network/Global/IPv4"])
Switches the active network location to the one with the given name or UUID.
Pass the location's display name (e.g. "Home") or its UUID from configurationLocations().
The change is applied immediately. Returns false if the location was not found or
the preferences could not be committed (e.g. insufficient privileges).
Creates a watcher that fires a callback when System Configuration dynamic store keys change.
Call setKeys() to specify which keys (or patterns) to watch, setCallback() to register
the handler, then start() to begin monitoring. The module automatically stops and
destroys all watchers on hs.reload().
Sends ICMP Echo Requests to server and reports results via a callback.
DNS resolution and the first ping begin immediately. The returned object can be used to
pause, resume, or cancel the ping, and to read statistics. The ping runs to completion,
with its callback, even if you don't keep a reference to it.
The options argument may be:
Omitted (or undefined) — uses all defaults.
A callback function — used as the event handler with all other options at their defaults.
An object with any of: count (integer, default 5), interval (seconds, default 1.0),
timeout (seconds per packet, default 2.0), family ("any" | "ipv4" | "ipv6", default "any"),
and callback (function).
The callback receives (ping, event, info):
"didStart" — info is the resolved IP address string.
"didFail" — info is an error message string (e.g. DNS failure).
"sendPacketFailed" — info is [packetObject, errorString].
"receivedPacket" — info is the packet object (see HSNetworkPing.packets()).
"didFinish" — info is the summary string.
Declaration
hs.network.ping(server, options) -> HSNetworkPing
Parameters
Name
Type
Description
server
string
A hostname or IP address to ping.
options
JSValue
A callback function or options object. Optional.
Returns
HSNetworkPing
An HSNetworkPing object, or null if the arguments are invalid.