react-ip-location
v1.0.37
Published
Get your ip address and location with just a single line of code; get location information of a provided ip address
Maintainers
Readme
react-ip-location
Simplest, lightest and fastest JS library to get your ip address and location.
Check current location by a provided ip address.
Table of Contents
Features
- getIPLocation();
- checkIPLocation('your-ip-address');
- Supports the Promise
Browser Support
|
|
|
|
|
|
--- | --- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
Installing
Package manager
Using yarn:
$ yarn add react-ip-locationUsing npm:
$ npm install react-ip-locationUsage
import React from 'react';
import { getIPLocation, checkIPLocation, getIPAddress } from 'react-ip-location';
export const App = () => {
// In your component
const getMyIP = async () => {
const location = await getIPLocation(); // { ip: "116.255.54.11", country: "AU" }
const checkLocation = await checkIPLocation('42.115.92.231'); // // { ip: "42.115.92.231", country: "AU" }
const ip = await getIPAddress(); // 116.255.54.11
};
getMyIP();
return <div>PAGE COTNENT</div>
};License
MIT © WillyVox
