Skip to main content

getAllGoogleFontsUrls

Returns an array of all unique Google Fonts URLs used across all font pairings in the registry.

Function Signature

lib/pairings.ts

Returns

urls
string[]
Array of all unique Google Fonts URLs across all pairings

Description

The getAllGoogleFontsUrls() function extracts and returns all unique Google Fonts URLs from every pairing in the registry. Each URL contains the font families and weights needed for a pairing. This is useful for preloading fonts, analyzing font usage, or building font loading strategies.

Usage Examples

Basic Usage

Preload All Fonts

Generate Font Loading Stylesheet

Check Font Loading Performance

Generate Next.js Font Configuration

Build Font Subset Optimizer

URL Format

Each Google Fonts URL follows this format:
Example:
URLs typically include multiple font families (heading, body, mono) with their respective weights combined in a single request for optimal loading performance.

getPairingGoogleFontsUrl

Get Google Fonts URL for a specific pairing

getAllPairings

Get all available pairings

Notes

  • URLs are extracted from the googleFontsUrl field of each pairing
  • The function deduplicates URLs automatically using a Set
  • Returns an array of strings in no particular order
  • Pairings without a googleFontsUrl are skipped (though all current pairings include this field)
  • Each URL is already optimized with display=swap for better performance
  • Performance: O(n) where n is the number of pairings

Best Practices

Add preconnect hints in your HTML head to speed up font loading:
All Fonttrio URLs include display=swap by default, which shows fallback text immediately while fonts load.
Consider adding subset parameters if you only need specific character sets (latin, latin-ext, cyrillic, etc.).

Source Reference

Implementation: lib/pairings.ts:53-61