In order to make FA icons usable in both server-side and client-side, you need to manually import those you want to use in the _app
component, as follow:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { config, library } from '@fortawesome/fontawesome-svg-core';
import '@fortawesome/fontawesome-svg-core/styles.css';
// Import your icons, and then add them to the libary
import { faGithub } from '@fortawesome/free-brands-svg-icons';
import { faBook, faBookReader, faCoffee, faHome, faUserCog } from '@fortawesome/free-solid-svg-icons';
// See https://github.com/FortAwesome/react-fontawesome#integrating-with-other-tools-and-frameworks
config.autoAddCss = false; // Tell Font Awesome to skip adding the CSS automatically since it's being imported above
library.add(
faGithub,
faBook, faBookReader, faCoffee, faHome, faUserCog,
);
You can then use FA icons like this:
Using the below code:
1
2
3
4
<FontAwesomeIcon icon={['fab', 'github']} /> // fab stands for FontAwesome "Brand"
<FontAwesomeIcon icon={['fas', 'home']} /> // fas stands for FontAwesome "Solid"
<FontAwesomeIcon icon={['fab', 'github']} />
, by telling you if the icon is valid.Custom Testing - 2021
Tous droits réservés