spatie/laravel-google-fonts
Self-host Google Fonts in Laravel with minimal setup. Register Google Fonts CSS URLs, then use the @googlefonts Blade directive to inline locally cached CSS and assets. Automatically downloads on first request, with a safe fallback to Google if needed.
file_get_contents + asset storage) and leverage Spatie’s battle-tested solution (MIT license, active maintenance)..woff2 files with manual @font-face in CSS). Only adopt if you want to simplify Google Font integration.@import Google Fonts directly in CSS).*"This package lets us self-host Google Fonts in our Laravel app, giving us three key advantages:
*"This solves a common pain point: Google Fonts are slow, block rendering, and introduce privacy/compliance risks. The package:
.woff2 files, and caches them locally on first request. No manual asset management.@googlefonts) and config-driven font registration. Example:
// config/google-fonts.php
'fonts' => [
'brand' => 'https://fonts.googleapis.com/css2?family=Brand+Sans:ital,wght@...',
];
@googlefonts('brand') <!-- Injected into <head> -->
FontDownloaded events to log usage or trigger analytics.
Tradeoff: Adds ~50KB to your deploy size (one-time cost). Worth it for [Z metric, e.g., ‘Lighthouse score’ or ‘offline PWA support’]."**"This gives you full control over typography without sacrificing performance:
wght@400;700 instead of the full family).@googlefonts('brand') <!-- Loads your custom font -->
No more fighting with @font-face or CDN delays!"*
How can I help you explore Laravel packages today?