Categories
React Answers

How to add favicon with React and Webpack?

Spread the love

Sometimes, we want to add favicon with React and Webpack.

In this article, we’ll look at how to add favicon with React and Webpack.

How to add favicon with React and Webpack?

To add favicon with React and Webpack, we can use the react-favicon library.

To install it, we run

npm install react-favicon

Then we use it by writing

import Favicon from "react-favicon";
//...

ReactDOM.render(
  <div>
    <Favicon url="/path/to/favicon.ico" />
  </div>,
  document.querySelector(".react")
);

to add the Favicon component and set the favicon location with the path prop.

Conclusion

To add favicon with React and Webpack, we can use the react-favicon library.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *