Note:
https://github.com/rohanray/next-fonts/issues/34
This plugin was created more than 2 years back (early 2018). Nextjs did not have first class support for importing fonts without using plugins during those days. Hence, this plugin might not be needed for current and newer versions of Next.js. Please seeNext.js + Fonts
Import fonts in Next.js (woff, woff2, eot, ttf, otf & svg)
Installation
npm install --save next-fonts
or
yarn add next-fonts
Usage
Create a next.config.js
in your project
// next.config.jsconst withFonts = ;moduleexports = ;
Optionally you can add your custom Next.js configuration as parameter
// next.config.jsconst withFonts = ;moduleexports = ;
assetPrefix
You can serve remote resources by setting assetPrefix option.
Example usage:
// next.config.jsconst withFonts = ;moduleexports = ;
Include SVG fonts
You can also (optionally) include SVG fonts by setting enableSvg option.
Example usage:
// next.config.jsconst withFonts = ;moduleexports = ;
inlineFontLimit
Inlines fonts with sizes below inlineFontLimit to Base64. Default value is 8192.
Example usage:
// next.config.jsconst withFonts = moduleexports =
Examples repository
Please see https://github.com/rohanray/next-fonts-example for usage with Nextjs v9.2+
Styled components
Please see https://github.com/rohanray/next-fonts-example/tree/master/with-styled-comp for sample code to use with styled components. Live URL : https://type-error-idfldxadbv.now.sh