astro-assets

Optimizes images, fonts, and OG images in Astro using the astro:assets module.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill astro-assets-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: astro-assets
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/astro-expert/skills/astro-assets
Command: npx skills add https://github.com/fusengine/kimi-code --skill astro-assets-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @astrojs/sharp, satori, @resvg/resvg-js, and includes references (resource) components.

What problem does it solve? Manually handling image optimization, responsive formats, font loading, and social preview images in Astro projects leads to layout shift, slow pages, and inconsistent implementations. This Skill provides structured guidance for the astro:assets module so images, fonts, and OG images are configured correctly the first time. ## Core Features & Use Cases - Image Optimization: Use <Image /> and <Picture /> for automatic WebP/AVIF conversion, responsive srcset/sizes, and priority loading for above-the-fold content. - Remote & Server-Side Images: Handle external CDN images with inferSize and authorized domains, plus getImage() for CSS backgrounds and API routes. - Fonts & OG Images: Configure the stable Fonts API for zero-CLS font loading and generate dynamic OG images with Satori at build time. - Use Case: A blog built with Astro needs responsive hero images, self-hosted Google Fonts without layout shift, and a unique OG image per post — this Skill walks through each setup with ready-to-use templates. ## Quick Start Ask the agent to set up optimized responsive images and the Fonts API in your Astro project using astro:assets.

Frequently Asked Questions about astro-assets

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize images in Astro with astro:assets?▼

Import the Image component from astro:assets and pass a local image import as src with a required alt attribute. Astro automatically infers dimensions and outputs WebP; add widths and sizes props for responsive srcset generation.

What is the difference between Image and Picture components in Astro?▼

The Image component outputs a single optimized img element, while Picture generates source elements for multiple formats like AVIF and WebP with a fallback img. Use Picture when you need format fallbacks or art direction across viewports.

How do I load Google Fonts in Astro without layout shift?▼

Use the stable Fonts API by adding a fonts array with fontProviders.google() in astro.config.mjs, then render the Font component with your cssVariable in the layout head. It applies font-display: optional and automatic preloading to eliminate CLS.

Can Astro optimize images from remote CDNs like Cloudinary?▼

Yes, authorize the CDN domain in the image config using domains or remotePatterns, then use the Image component with the remote URL. Add inferSize when dimensions are unknown, or configure a custom image service entrypoint for Cloudinary or Imgix transformations.

How do I generate dynamic OG images in Astro?▼

Create a dynamic API route like src/pages/og/[slug].png.ts that uses Satori to render an SVG from a JSX-like object and Resvg or Sharp to convert it to PNG. Run it at build time via getStaticPaths since Satori rendering is expensive for SSR.

Why does my remote image fail to optimize in Astro?▼

Astro only optimizes images from authorized domains by default, so unlisted hosts are blocked for security. Add the hostname to image.domains or image.remotePatterns in astro.config.mjs, and use inferSize if width and height are unknown.