https://github.com/jaywcjlove/local-ip-url
Get current machine IP.
https://github.com/jaywcjlove/local-ip-url
address ip ipv4 ipv6 ipv6-network mac
Last synced: about 1 month ago
JSON representation
Get current machine IP.
- Host: GitHub
- URL: https://github.com/jaywcjlove/local-ip-url
- Owner: jaywcjlove
- License: mit
- Created: 2018-06-21T15:58:07.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-11T06:23:55.000Z (about 1 year ago)
- Last Synced: 2025-04-21T18:21:48.016Z (about 2 months ago)
- Topics: address, ip, ipv4, ipv6, ipv6-network, mac
- Language: JavaScript
- Homepage: https://jaywcjlove.github.io/local-ip-url
- Size: 108 KB
- Stars: 20
- Watchers: 4
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
local-ip-url
===[](https://jaywcjlove.github.io/#/sponsor)

[](https://jaywcjlove.github.io/local-ip-url/lcov-report/)
[](https://github.com/react-doc/local-ip-url/network)
[](https://github.com/react-doc/local-ip-url/stargazers)
[](https://github.com/react-doc/local-ip-url/releases)
[](https://npmjs.org/package/local-ip-url)Get current machine IP.
## Install
```bash
npm install local-ip-url --save-dev
```## Usage
```js
const localIpUrl = require('local-ip-url');
localIpUrl() // => 192.168.31.69
localIpUrl('public') // => 192.168.31.69
localIpUrl('public', 'ipv4') // => 192.168.31.69
localIpUrl('public', 'ipv6') // => fe80::c434:2eff:fe06:f90
localIpUrl('private') // => 127.0.0.1
localIpUrl('private', 'ipv4') // => 127.0.0.1
localIpUrl('private', 'ipv6') // => fe80::1
``````js
const prepareUrls = require('local-ip-url/prepareUrls');prepareUrls({
protocol: 'http',
host: '0.0.0.0',
port: 3001
});// ===output==>
// {
// ip: '192.168.31.69',
// localUrl: 'http://localhost:3001/',
// lanUrl: 'http://192.168.31.69:3001/'
// }
```## Contributors
As always, thanks to our amazing contributors!
Made with [contributors](https://github.com/jaywcjlove/github-action-contributors).
## License
MIT