react-ip-finder
v1.0.1
Published
Simple NPM package to fetch IP
Downloads
22
Maintainers
Readme
Best NPM package to fetch IP details using the ipinfo.io API.
Installation
npm install react-ip-finder
Usage
import { getIPDetails } from 'react-ip-finder';
getIPDetails().then(ipDetails => {
console.log('IP Details:', ipDetails);
}).catch(error => {
console.error('Error fetching IP details:', error);
});
Example
import React, { useEffect, useState } from 'react';
import { getIPDetails, IPDetails } from 'react-ip-finder';
const App = () => {
const [ipDetails, setIpDetails] = useState<IPDetails | null>(null);
useEffect(() => {
getIPDetails().then(setIpDetails).catch(error => console.error('Error fetching IP details:', error));
}, []);
if (!ipDetails) return <div>Loading...</div>;
return (
<div>
<h1>Your IP Details</h1>
<p><strong>IP:</strong> {ipDetails.ip}</p>
</div>
);
};
export default App;
License
This package is licensed under the ISC License.
This README.md
provides clear instructions on how to install, use the package, and obtain the necessary API token from ipinfo.io.