Capture an IP using React - Perfect for Sign In, Stripe Terms of Service, etc.

Capturing an IP is fairly simple, and can be done with React. In this tutorial, I’ll show you the little bit of code needed. You must have Node installed. We will use this code base as a starting point. Download or clone it, then run the following commands:

npm install
npm run start

The app will start up on http://localhost:3000. Open the src/App.js. You can change it to be:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class App extends Component {
  componentWillMount() {
    fetch('', {
      method: 'GET',
      headers: {},
    .then(res => {
      return res.text()
    }).then(ip => {
      console.log('ip', ip);

  render() {
    return (
      div className="App">
        div className="App-header">
          img src={logo} className="App-logo" alt="logo" />
          h2>Welcome to React/h2>
        p className="App-intro">
          To get started, edit code>src/App.js/code> and save to reload.

export default App;

As you can see this will call the IPify API. It will return your IP. This IP will be excellent for Term of Services and Analytics.