Introduction
Astro helps you build fast websites by loading only what is needed. It makes your site quick and easy to maintain.
Astro helps you build fast websites by loading only what is needed. It makes your site quick and easy to maintain.
--- import Component from './Component.astro'; --- <html> <head> <title>My Astro Site</title> </head> <body> <Component /> </body> </html>
.astro extension and combine HTML with JavaScript.--- marks the start and end of the script section where you import or write code.---
const name = 'Friend';
---
<h1>Hello, {name}!</h1>--- import Button from './Button.astro'; --- <Button text="Click me" />
This is a simple Astro page that shows a welcome message and a short description. It uses JavaScript inside the script section to set the message.
--- const message = 'Welcome to Astro!'; --- <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Astro Sample</title> </head> <body> <h1>{message}</h1> <p>This site loads only what you need.</p> </body> </html>
Astro focuses on delivering static HTML by default, which helps pages load faster.
You can add interactive parts with JavaScript only when needed, saving resources.
Astro works well with many popular web tools and frameworks.
Astro builds fast websites by sending less code to the browser.
It uses simple files that mix HTML and JavaScript.
Great for beginners who want quick, efficient sites.
<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