0

im really confused what is the best way to integrate fontawesome to reactjs web app using CDN or installing NPM for production ecommerce i also use webpack for react

Harshit Singh
  • 27
  • 1
  • 5

3 Answers3

1

I suggest npm.. react font awesome icon

Avani Bataviya
  • 750
  • 1
  • 6
  • 20
1

CDN is basically another request to some server. Since, your browser can run concurrently process only 5 requests using more cdn makes browser bit slower at first.

I prefer to use npm package for react

NEWGIN SAM
  • 129
  • 2
  • 7
1

You can use Fontawesome npm package. When you use npm package, just used icons will add to your component. This help page size while loading.

Step 1 ) Add packages with npm:

npm i --save @fortawesome/fontawesome-svg-core
npm install --save @fortawesome/free-solid-svg-icons
npm install --save @fortawesome/react-fontawesome

Or for free regular icons:

npm install --save @fortawesome/free-regular-svg-icons

Step 2 ) Import fontawesome to your component:

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'

Step 3 ) Import icon that you need:

import { faCoffee } from '@fortawesome/free-solid-svg-icons'

Step 4 ) Add jsx tag where you want in return function in component:

<FontAwesomeIcon icon={faCoffee} />
Danial
  • 1,603
  • 2
  • 15
  • 24