@ref_digital/nuxt-fonts
v1.0.0
Published
@nuxt/fonts, with Adobe Fonts served from Adobe's servers (as their licence requires) instead of self-hosted. Same config, preloads included.
Readme
@ref_digital/nuxt-fonts
@nuxt/fonts, with Adobe Fonts served from Adobe's servers, as their licence requires. Same config, same preload option. Everything else is plain @nuxt/fonts.
- Why
- Getting started
- Configuration
- What it adds to the page
- Differences from
@nuxt/fonts - Compatibility
- Troubleshooting
Why
@nuxt/fonts self-hosts every font it resolves. At build time, it downloads the files from the provider and serves them from your own domain (/_fonts/…). That works well for Google Fonts and other open fonts.
It doesn't work for Adobe Fonts. Their terms only cover fonts loaded through your Adobe web project (the "kit"), from Adobe's servers. When the files are self-hosted:
- the site is no longer covered by your Adobe Fonts licence, even though you pay for it;
- Adobe's usage tracking (
p.typekit.net) never runs, so foundries see their fonts on your domain without the usage behind them. That's how they detect it, and then they contact you about the licence.
This module keeps @nuxt/fonts for everything else, and loads Adobe families the way Adobe requires: with the kit stylesheet from use.typekit.net, plus the preloads you configure.
Getting started
1. Install
npm install --save-dev @ref_digital/nuxt-fonts @nuxt/fonts
# or: yarn add --dev / pnpm add --save-dev@nuxt/fonts is a peer dependency: you keep control of its version.
2. Replace @nuxt/fonts in modules
// nuxt.config.ts
export default defineNuxtConfig({
modules: [
- "@nuxt/fonts",
+ "@ref_digital/nuxt-fonts", // sets up @nuxt/fonts for you
],
});3. Configure fonts as usual, in fonts
// nuxt.config.ts
export default defineNuxtConfig({
modules: ["@ref_digital/nuxt-fonts"],
fonts: {
// Your Adobe web project id ("kit" id), from fonts.adobe.com → Web Projects.
adobe: { id: "abc1234" },
families: [
// Served by Adobe, from use.typekit.net
{ name: "Proxima Nova", provider: "adobe", preload: true, weights: [500, 700] },
// Self-hosted by @nuxt/fonts, as before
{ name: "Inter", provider: "google", preload: true },
{ name: "My Font", provider: "local", src: "/fonts/my-font.woff2" },
],
},
});4. Use Adobe's CSS family names
The kit stylesheet declares families under their CSS names. Adobe shows them in the web project, and they're usually the font name in kebab case:
body {
font-family: "proxima-nova", sans-serif; /* not "Proxima Nova" */
}In fonts.families, use either the font name ("Proxima Nova") or the CSS name ("proxima-nova").
That's it. Build, and check that <head> loads https://use.typekit.net/<kit id>.css.
Configuration
There's no separate config: the module reads the @nuxt/fonts options in fonts. These options apply to Adobe families:
| Option | What it does for Adobe families |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| fonts.adobe.id | Kit id, or an array of kit ids. Each kit stylesheet is added to <head>. |
| families[].provider: "adobe" | Serves the family from Adobe. Other providers keep working through @nuxt/fonts. |
| fonts.provider: "adobe" | Serves every family without provider or src from Adobe. |
| families[].preload | Same values as @nuxt/fonts, see below. Defaults to fonts.defaults.preload. |
| families[].weights, families[].styles | Limit which faces of the kit can be preloaded (e.g. weights: [500, 700]). |
preload
| Value | Preloads |
| --------------------------- | -------------------------------------------------------------------------------------------- |
| false / unset | nothing (the default) |
| true | the single best face: upright, with the weight closest to 400 |
| { weights?, styles? } | every face matching all the filters, e.g. { weights: [400, 700], styles: ["normal"] } |
| (family, face) => boolean | every face the function accepts. face has family (CSS name), style, weight and src |
Preload only what shows above the fold. Every preloaded file competes with your other critical requests, such as the LCP image.
All other options (defaults, providers, experimental, …) go to @nuxt/fonts unchanged.
What it adds to the page
With adobe: { id: "abc1234" } and one preloaded face, <head> starts with:
<link rel="preconnect" href="https://use.typekit.net" crossorigin="anonymous">
<link rel="preconnect" href="https://p.typekit.net">
<link rel="stylesheet" href="https://use.typekit.net/abc1234.css">
<link rel="preload" as="font" type="font/woff2" href="https://use.typekit.net/af/…/l?…" crossorigin="anonymous">- The stylesheet is render-blocking on purpose. The
@font-facerules exist before the first paint, so text never renders with a stylesheet that is still loading. Same as@nuxt/fonts, which bundles its rules into your CSS. - Preloads point to the exact woff2 files from the kit, read from the published kit stylesheet at build time. The browser fetches them right away instead of waiting for the CSS.
- The kit stylesheet
@imports Adobe's usage tracking. Don't strip it: it's what keeps you within the licence.
On the @nuxt/fonts side, Adobe families are removed and the adobe provider is disabled. The kit's family names are also registered with provider: "none", so @nuxt/fonts doesn't look them up with another provider when it finds them in your CSS.
Differences from @nuxt/fonts
These apply to Adobe families only. Other families get everything @nuxt/fonts does.
- No generated fallback faces (size-adjusted fallbacks). They need the font files at build time, which Adobe's licence doesn't allow.
font-displayis set in the Adobe web project (Web Projects → Font display), not innuxt.config.ts.- Preloads are resolved at build time. If you republish the kit (new fonts, changed settings), rebuild so the preload URLs match the kit again.
subsets, route rule preloads and per-familyfallbacksdon't apply, since Adobe kits are fixed by the web project.
Compatibility
| | Supported |
| ------------- | --------------------------------------------- |
| Nuxt | 3.19+ and 4.1+ |
| @nuxt/fonts | >=0.11.0 <2 (tested with 0.11 and 1.x) |
| Node | whatever your Nuxt version supports (≥ 18.12) |
Nuxt 2 isn't supported, because @nuxt/fonts itself requires Nuxt 3+. On Nuxt 2, load the kit directly from Adobe: app.head link: [{ rel: "stylesheet", href: "https://use.typekit.net/<kit id>.css" }].
Troubleshooting
@nuxt/fonts was set up before this module
@nuxt/fonts is listed before @ref_digital/nuxt-fonts in modules (maybe through a layer), so it already self-hosted the Adobe fonts. Remove it from modules, or list it after this module.
Could not read Adobe kit …
The build couldn't fetch https://use.typekit.net/<id>.css (offline, wrong id, unpublished kit). Fonts still load in the browser, but nothing is preloaded. Check the id and that the web project is published.
… is not in Adobe kit(s) …
The family name doesn't match any family in the kit. The warning lists the kit's CSS names: use one of them, or add the font to the web project.
Fonts don't show on a domain
Adobe only serves kits on the domains listed in the web project. Add production, staging and localhost in Web Projects → Domains.
Fonts render with the fallback
Check that CSS uses the kit's CSS name ("proxima-nova"), not the display name.
License
MIT. Adobe Fonts and Typekit are trademarks of Adobe. This project isn't affiliated with Adobe or Nuxt.
