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
Asked
Active
Viewed 1,568 times
3 Answers
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
-
Which one should i use for free icons step 1 or step 2 – Harshit Singh Jul 22 '21 at 07:56
-
For free icons, do it step by step. All steps. – Danial Jul 22 '21 at 09:17