react-ip-location
TypeScript icon, indicating that this package has built-in type declarations

1.0.24 • Public • Published

react-ip-location

  • Simplest, lightest and fastest JS library to get your ip address and location.

  • Check current location by a provided ip address.

NPM JavaScript Style Guide

Table of Contents

Features

  • getIPLocation();
  • checkIPLocation('your-ip-address');
  • Supports the Promise

Browser Support

Chrome Firefox Safari Opera Edge IE
Latest Latest Latest Latest Latest 11

Installing

Package manager

Using yarn:

$ yarn add react-ip-location

Using npm:

$ npm install react-ip-location

Usage

import React from 'react';
import { getIPLocation, checkIPLocation } from 'react-ip-location';


export const App = () => {
  getIPLocation().then(result => {
    // console.log(result);
  });
  checkIPLocation('42.115.92.231').then(result => {
    // console.log(result);
  });

  // Or declare an async function in your component
  const getMyIP = async () => {
      const location = await getIPLocation();
      return console.log("my location", location);
  };
  
  getMyIP();

  return <div>PAGE COTNENT</div>

};

License

MIT © HFrontend


Package Sidebar

Install

npm i react-ip-location

Weekly Downloads

226

Version

1.0.24

License

ISC

Unpacked Size

56.6 kB

Total Files

20

Last publish

Collaborators

  • huyfrontend