Use React with...
You can use the Font Awesome React component with Next.js or TypeScript.
Next.js
The react-fontawesome
component integrates well with Next.js but there is one caveat you need to solve.
Since Next.js manages CSS differently than most web projects if you just follow
the plain vanilla documentation to integrate react-fontawesome
into your
project you’ll see huge icons because they are missing the accompanying CSS
that makes them behave.
Getting Font Awesome CSS to Work
Let’s assume that you have a standard install using TypeScript.
Modify src/app/layout.tsx
, adding the import for Font Awesome’s supporting stylesheet.
import type { Metadata } from "next";import { Inter } from "next/font/google";import "./globals.css";
import { config } from '@fortawesome/fontawesome-svg-core'import '@fortawesome/fontawesome-svg-core/styles.css'config.autoAddCss = false
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = { title: "Create Next App", description: "Generated by create next app",};
export default function RootLayout({ children,}: Readonly<{ children: React.ReactNode;}>) { return ( <html lang="en"> <body className={inter.className}>{children}</body> </html> );}