Performance: Why Astro components use a unique format
This affects how fast the page loads and how much JavaScript runs in the browser, improving initial load speed and interaction responsiveness.
---
const message = 'Hello';
---
<div>{message}</div><script>import React from 'react'; export default function Component() { return <div>Hello</div>; }</script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Astro static component | Minimal DOM nodes | 0 reflows on load | Low paint cost | [OK] Good |
| React full client component | More DOM nodes | Multiple reflows during hydration | Higher paint cost | [X] Bad |
--- for JavaScript.---
const name = 'Astro';
--- uses the correct frontmatter syntax; others use React or HTML script tags not used in Astro.---
const greeting = 'Hi';
---
<h1>{greeting}, Astro!</h1>greeting is defined in the frontmatter and used inside the HTML with curly braces.{greeting} with its value 'Hi', so the output is <h1>Hi, Astro!</h1>.---
const title = 'Welcome'
---
<h1>{title}</h1>Pass the test and this pattern moves unknown