Published on

Getting Your Public IP Address in JavaScript


If you want to get a public IP address then public-ip npm package might be a good choice for you.

With this library, you can easily get IP addresses both IPv4 and IPv6. And it supports both the browser and node as well.


npm install public-ip


import {publicIp, publicIpv4, publicIpv6} from 'public-ip';
console.log(await publicIp()); // Falls back to IPv4
console.log(await publicIpv6()); // IPv6: fe80::200:f8ff:fe21:67cf
console.log(await publicIpv4()); // IPv4:

Happy getting-public IP!