Public IP is a JavaScript package for quickly determining a device's externally visible IP address. It provides separate functions for IPv4, IPv6, or automatic detection that prefers IPv6 and falls back to IPv4. In Node.js, the package queries multiple DNS and HTTPS services to improve reliability. Browser environments use HTTPS-based public IP services instead of DNS queries. Operations are asynchronous and can be given explicit timeouts to avoid waiting indefinitely for unavailable services. AbortSignal support lets applications cancel an active lookup when it is no longer needed. A dedicated error type distinguishes cases where the package cannot determine a public address, making it useful for diagnostics, networking tools, and environment detection.
Features
- Automatic public IP detection
- Dedicated IPv4 and IPv6 lookup functions
- Multiple DNS and HTTPS lookup providers
- Node.js and browser support
- Timeout and AbortSignal cancellation
- Dedicated IP-not-found error handling