To get the browser name in react js, install the platform package and call platform.name it will return the browser name.

Take the example of using the platform package to get the browser name in react js.

import platform from 'platform';


platform.name; // 'IE' ( your users browser name )

Today, I’m going to show you How do I get the browser name in react js, as above mentioned here, I’m going to use the platform package to check the browser name.

Let’s start today’s tutorial how do you get the browser name in react js?

In this example, we will do

  1. Install the platform package
  2. Use the platform.name method in function and console the output.
  3. Print browser name on screen
import React, { useState, useEffect } from "react";
import platform from 'platform';
export default function App() {
    const [name, setName] = useState("");
     useEffect(() => {
        setName(platform.name);

    console.log(platform.name);
    }, []);
  return (
    <div className="App">
      <p>{`browser name: ${name}`}</p>
    </div>
  );
}

In the above example, we are getting the browser name and printing it in the screen.

I hope it helps you, All the best 👍.