getPairingGoogleFontsUrl
Returns the Google Fonts URL for a specific font pairing by name.Function Signature
lib/pairings.ts
Parameters
The name of the pairing (e.g., “editorial”, “minimal”, “brutalist”)
Returns
The Google Fonts URL for the pairing, or
null if the pairing is not found or has no URL configuredDescription
ThegetPairingGoogleFontsUrl() function retrieves the Google Fonts URL for a specific pairing. This URL includes all three fonts (heading, body, mono) with their required weights, optimized for loading in a single request.
Usage Examples
Basic Usage
Load Fonts Dynamically
Preload Pairing Fonts
Next.js Font Loading
Error Handling
Generate Font Preconnect Tags
URL Format
The returned URL follows the Google Fonts API v2 format:- Heading font: Playfair Display (weights: 600, 700)
- Body font: Source Serif 4 (weights: 400, 600)
- Mono font: JetBrains Mono (weights: 400, 500)
- Display strategy: swap (shows fallback text immediately)
Return Value
- Returns the full Google Fonts URL as a string if the pairing exists
- Returns
nullif:- The pairing name is not found in the registry
- The pairing exists but has no
googleFontsUrlfield (rare)
Related Functions
getPairing
Get full pairing data including fonts and scale
getAllGoogleFontsUrls
Get all Google Fonts URLs across pairings
Notes
- The function internally calls
getPairing()to fetch the pairing data - Pairing names are case-sensitive (use lowercase names like “editorial”, not “Editorial”)
- All current pairings include a Google Fonts URL, but the function returns
nullfor safety - URLs include
display=swapfor optimal loading performance - Performance: O(n) where n is the number of pairings (linear search)
Common Pairings
Editorial Pairings
Editorial Pairings
editorial- Playfair Display + Source Serif 4 + JetBrains Monoliterary- EB Garamond + Crimson Text + Inconsolatanewspaper- Playfair Display + DM Sans + JetBrains Mono
Clean Pairings
Clean Pairings
minimal- Inter + Inter + JetBrains Monomodern-clean- Space Grotesk + Space Grotesk + Space Monoswiss- Work Sans + Work Sans + Source Code Pro
Bold Pairings
Bold Pairings
brutalist- Space Grotesk + Space Grotesk + Space Monoimpact- Bebas Neue + Barlow + Fira Codeposter- Alfa Slab One + Assistant + Roboto Mono
Source Reference
Implementation:lib/pairings.ts:63-66