Index of every page on this site: llms.txt

The module bundles Inter (400 and 700) and it works by default with zero configuration.

For any other font, Nuxt OG Image uses the @nuxt/fonts module. The module does not support any other method of loading custom fonts.

Setup

  1. Install @nuxt/fonts:
pnpm exec nuxt module add @nuxt/fonts

Nuxt OG Image v7 requires @nuxt/fonts 1.0.0 or newer. With an older version, OG images use the bundled Inter font.

  1. Configure your fonts in nuxt.config.ts. Set global: true for fonts used only in OG images.
nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxt/fonts', 'nuxt-og-image'],

  fonts: {
    families: [
      { name: 'Roboto', weights: [400, 700], global: true },
    ],
  },
})
The global: true option resolves a family independently of your site's CSS. Families used in site CSS also become available when @nuxt/fonts resolves them. In development, refresh the preview after that stylesheet loads if the first image uses a fallback.

Usage

Once configured, simply use the font family in your component styles:

components/OgImage/MyTemplate.vue
<template>
  <div style="font-family: 'Roboto', sans-serif">
    <h1>{{ title }}</h1>
  </div>
</template>

Advanced Configuration

Provider Configuration

You can use any provider supported by @nuxt/fonts:

nuxt.config.ts
export default defineNuxtConfig({
  fonts: {
    families: [
      // Google Fonts (default provider)
      { name: 'Roboto', weights: [400, 700], global: true },

      // Explicit provider
      { name: 'Inter', provider: 'bunny', weights: [400, 700], global: true },

      // Local font files
      {
        name: 'MyFont',
        src: '/fonts/MyFont.woff2',
        weight: 400,
        global: true,
      },
    ],
  },
})

Font Format Support

Different renderers support different font formats:

FormatSatoriTakumiBrowser
woff2❌✅✅
woff✅⚠️✅
ttf✅✅✅
otf✅✅✅
This table describes native renderer support. Nuxt OG Image converts static WOFF2 files to TTF for Satori. Takumi's Wasm build rejects WOFF, so Nuxt OG Image converts WOFF files to TTF or OTF before rendering. Variable fonts need static alternatives for Satori. Takumi uses variable fonts directly. If conversion or resolution fails, the build reports the fallback.

Troubleshooting

Font not rendering

  1. Ensure the font has global: true set in your nuxt.config.ts.
  2. Ensure the font is listed in fonts.families.
  3. For local fonts, ensure the format matches your renderer (see table above).

China/Blocked regions

For regions where Google Fonts is blocked, use local fonts or an alternative provider:

nuxt.config.ts
export default defineNuxtConfig({
  fonts: {
    providers: {
      google: false,
    },
    families: [
      {
        name: 'Inter',
        src: '/fonts/Inter-Regular.woff2',
        weight: 400,
        global: true,
      },
    ],
  }
})

Why is this required?

OG Image generation happens in a server-side or build-time environment where the DOM and standard browser font loading are not available. The @nuxt/fonts module provides the necessary hooks to resolve, download, and buffer font files so they can be embedded directly into the image generation process (Satori, Takumi, etc.).

Manual font loading, CSS @font-face rules in global CSS files, or CDN links will not work.

Was this page helpful?