Concept Flow - What is Astro
Start Project
Write Components
Astro Builds Static HTML
Serve Fast Pages
User Sees Content Quickly
Astro lets you build websites by writing components that it compiles into fast static HTML pages served to users.
---
const title = "Hello from Astro";
---
<html>
<head><title>{title}</title></head>
<body><h1>{title}</h1></body>
</html>| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Start Astro build | Load component code | Component code ready |
| 2 | Evaluate frontmatter | const title = "Hello from Astro" | title = "Hello from Astro" |
| 3 | Render HTML template | Insert {title} in <title> and <h1> | <title>Hello from Astro</title> and <h1>Hello from Astro</h1> |
| 4 | Generate static HTML file | Combine rendered HTML | Static HTML page created |
| 5 | Serve page to user | User requests page | User sees fast static page with title |
| 6 | End | No more actions | Build complete |
| Variable | Start | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|
| title | undefined | "Hello from Astro" | "Hello from Astro" | "Hello from Astro" |
Astro builds fast websites by compiling components into static HTML. Use frontmatter (---) to run server code at build time. Templates insert variables into HTML. Result: lightweight pages that load quickly. No heavy JavaScript runs in the browser by default.
<script> block exporting default to define behavior.<Component>Hello</Component> <script>export default {};</script> shows HTML markup with a <script> exporting default, which is correct. <Component>Hello</Component> lacks script, B is React style, C is just HTML without component structure.<script>
export let name = 'Friend';
</script>
<h1>Hello, {name}!</h1>name has a default value 'Friend' if no prop is passed.name remains 'Friend', so the output is <h1>Hello, Friend!</h1>.<script>
let count = 0;
</script>
<button onClick={() => count++}>Click</button>
<p>Count: {count}</p><script> block to receive the list, then a map in the markup with a condition to add a CSS class for long names uses Astro's built-in features to map and conditionally style names, which is simple and efficient. Using React inside Astro adds unnecessary complexity, writing plain HTML with no scripting is static, and creating a server-side API is overkill for this task.<script> block to receive the list, then use a map in the markup with a condition to add a CSS class for long names [OK]Pass the test and this pattern moves unknown