Navigate back to the homepage

how to get browser name in react js?

Infinitbility
React
July 25th, 2022 · 1 min read
how to get browser name in react js?

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.

1import platform from 'platform';
2
3
4platform.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
  4. Final Result: Search filter in React
1import React, { useState, useEffect } from "react";
2import platform from 'platform';
3export default function App() {
4 const [name, setName] = useState("");
5 useEffect(() => {
6 setName(platform.name);
7
8 console.log(platform.name);
9 }, []);
10 return (
11 <div className="App">
12 <p>{`browser name: ${name}`}</p>
13 </div>
14 );
15}

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

I hope it helps you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

how to get browser version in react js?

how to get browser version in react js?

An example of get browser version in react js with step by step guide.

July 25th, 2022 · 1 min read
how to export constants in typescript?

how to export constants in typescript?

TypeScript, export constants example with the step-by-step guide.

July 24th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]