Skip to content

SakibFakir69/get-device-ip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

get-device-ip πŸš€

npm version License: MIT

A ultra-lightweight, zero-dependency Node.js utility to quickly find your machine's local IPv4 and IPv6 addresses.

Use this for Backend development

🌟 Why use this?

  • Zero Dependencies: No bloated node_modules.
  • Modern Node Support: Fully compatible with Node.js 18, 20, 22+ (handles both string and numeric family types).
  • Clean Output: Filters out internal loopback addresses (127.0.0.1) automatically.
  • Cross-Platform: Works on Windows, macOS, and Linux.

πŸ“¦ Installation

npm install get-device-ip
πŸš€ Usage
You can now use this package in any Node.js project without extra configuration.

Modern (ES Modules)
import { getDeviceIP } from 'get-device-ip';

const ip = getDeviceIP();
console.log('Primary IPv4:', ip.primaryIpv4);
console.log('All IPv4s:', ip.IPv4);

Legacy (CommonJS)
const { getDeviceIP } = require('get-device-ip');

const ip = getDeviceIP();
console.log('Primary IPv4:', ip.primaryIpv4);
πŸ“Š Return Object Structure

{
  IPv4: [ '192.168.0.100', '172.23.160.1' ],
  IPv6: [ 'fe80::2ecc:c31a:a1fc:dcf0' ],
  primaryIpv4: '192.168.0.100',
  primaryIpv6: 'fe80::2ecc:c31a:a1fc:dcf0'
}


πŸ“„ License MIT Β© Sakib Fakir

About

A ultra-lightweight, zero-dependency Node.js utility to quickly find your machine's local IPv4 and IPv6 addresses.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors