Dmitrii Posted on May 30 • Originally published at quotyai.com 22 Astro Best Practices: The Bookmark-Worthy Tips # javascript # astro # performance # webdev 22 Astro Best Practices: The Bookmark-Worthy Tips At QuotyAI I'm using Astro to build landing pages and blog posts, so I have hands-on experience how to use it properly and how to vibe-code without headache. Astro is the best framework for content sites right now - #1 in developer satisfaction in the State of JS 2025 survey, with Cloudflare backing it since January 2026. But like any tool, it rewards people who use it the way it was designed. This is the reference I wish I had when I started. Whether you're building your first Astro project or vibe-coding a blog at 2am, these are the habits worth forming from day one. Heads up on versions: This article covers Astro 6.x (released March 2026) and Astro 6.4 (released May 2026). Some APIs from older tutorials are now deprecated - those are called out explicitly below. Always check the upgrade guide when moving between majors. 🖼️ Assets & Media 1. Use <Image /> instead of <img /> Astro's built-in <Image /> component does a lot of work at build time that plain <img> tags leave on the table: it converts images to WebP, generates the right width and height attributes to prevent layout shift, and compresses everything without you touching a single config file. --- import { Image } from 'astro:assets'; import hero from '../assets/hero.png'; --- <!-- ✅ Optimized: converted to WebP, compressed, no layout shift --> <Image src={hero} alt="Hero image" /> <!-- ❌ Skips all of that --> <img src="/hero.png" alt="Hero image" /> Enter fullscreen mode Exit fullscreen mode For art-direction scenarios (different images at different breakpoints), reach for <Picture /> instead. 2. Use the Astro 6 Built-in Fonts API Almost every website uses custom fonts, but getting them right is surprisingly complicated - performance tradeo
LIVE
