micro-geoip-lite
🌍 An extremely lite geoip decoder utilizing the micro-geoip-lite microservice to geo decode the IP info via an https request - the microservice utilizes MaxMind's IP info dataset.
Installation
- Run
yarn add micro-geoip-light
, npm i micro-geoip-light
Usage
-
params:
- ip?: string - optional, defaults to client's IP
- options?:
{ serviceUrl: string }
- optional, called instead of the default provider URL. You can also provide this via an env var REACT_APP_SERVICE_URL_GEOIP
or SERVICE_URL_GEOIP
-
returns:
{
ip: string,
range: [ number, number ],
country: string,
region: string,
eu: string,
timezone: string,
city: string,
ll: [ number, number ],
metro: number,
area: number,
}
-
example - fetch own ip info:
import geodecodeIp from 'micro-geoip-light';
const result = await geodecodeIp();
{
ip: '207.97.227.239',
range: [ 3479298048, 3479300095 ],
country: 'US',
region: 'TX',
eu: '0',
timezone: 'America/Chicago',
city: 'San Antonio',
ll: [ 29.4969, -98.4032 ],
metro: 641,
area: 1000,
}
-
example - fetch specific ip info:
import geodecodeIp from 'micro-geoip-light';
const result = await geodecodeIp('207.97.227.239');
-
Live DEMO