Astro is a modern web framework that helps build fast websites by sending less JavaScript to the browser. It focuses on performance and uses components from many popular frameworks.
Click to reveal answer
beginner
How does Astro improve website speed?
Astro sends mostly static HTML to the browser and only loads JavaScript when needed. This reduces load time and makes websites faster.
Click to reveal answer
intermediate
Can Astro use components from other frameworks like React or Vue?
Yes, Astro allows you to use components from React, Vue, Svelte, and others all in the same project, making it flexible and easy to integrate.
Click to reveal answer
beginner
What is the main goal of Astro?
Astro aims to create websites that load quickly and perform well by minimizing JavaScript and focusing on static site generation.
Click to reveal answer
intermediate
Does Astro support server-side rendering (SSR)?
Yes, Astro supports server-side rendering, allowing dynamic content to be generated on the server before sending it to the browser.
Click to reveal answer
What is a key feature of Astro?
AIt sends mostly static HTML to the browser
BIt requires heavy JavaScript on the client
CIt only works with React components
DIt is a database management system
✗ Incorrect
Astro focuses on sending mostly static HTML to improve website speed.
Which frameworks can you use components from in Astro?
AOnly Astro components
BOnly Angular
COnly jQuery
DReact, Vue, Svelte, and others
✗ Incorrect
Astro supports components from many popular frameworks like React, Vue, and Svelte.
What does Astro minimize to improve performance?
AJavaScript sent to the browser
BCSS styles
CHTML content
DImage sizes
✗ Incorrect
Astro reduces the amount of JavaScript sent to the browser to speed up loading.
Does Astro support server-side rendering (SSR)?
ANo
BYes
COnly for static sites
DOnly with React
✗ Incorrect
Astro supports SSR to generate dynamic content on the server.
What is the main goal of Astro?
ATo build slow, heavy websites
BTo manage databases
CTo create fast, optimized websites
DTo replace all JavaScript frameworks
✗ Incorrect
Astro aims to build fast and optimized websites by minimizing JavaScript.
Explain what Astro is and how it helps improve website performance.
Think about how websites load faster with less JavaScript.
You got /4 concepts.
Describe how Astro allows using components from different frameworks in one project.
Imagine building a website using pieces from different toolkits.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of Astro?
easy
A. To design desktop software
B. To create mobile apps only
C. To manage databases efficiently
D. To build fast websites by sending less code to the browser
Solution
Step 1: Understand Astro's goal
Astro focuses on making websites load faster by reducing the amount of code sent to users' browsers.
Step 2: Compare options with Astro's purpose
The options describing desktop software, mobile apps only, and database management are unrelated tasks, which Astro does not specialize in.
Final Answer:
To build fast websites by sending less code to the browser -> Option D
Quick Check:
Astro purpose = fast websites with less code [OK]
Hint: Astro is about fast websites with less browser code [OK]
Common Mistakes:
Thinking Astro is for mobile apps
Confusing Astro with database tools
Assuming Astro builds desktop software
2. Which of the following is a correct way to write an Astro component file?
easy
A. <Component>Hello</Component> <script>export default {};</script>
B. function Component() { return <div>Hello</div>; }
C. <div>Hello</div>
D. <Component>Hello</Component>
Solution
Step 1: Identify Astro component structure
Astro components combine HTML markup with a <script> block exporting default to define behavior.
Step 2: Check options for correct Astro syntax
<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.
Final Answer:
<Component>Hello</Component> <script>export default {};</script> -> Option A
Quick Check:
Astro component = HTML + export default script [OK]
Hint: Astro components need HTML plus export default script [OK]
Common Mistakes:
Using React function syntax instead of Astro
Writing only HTML without export default
Missing the script block in component
3. Given this Astro component code:
<script>
export let name = 'Friend';
</script>
<h1>Hello, {name}!</h1>
What will be the rendered output if no props are passed?
medium
A.
Hello, Friend!
B.
Hello, !
C.
Hello, {name}!
D. Error: name is undefined
Solution
Step 1: Understand default prop value in Astro
The variable name has a default value 'Friend' if no prop is passed.
Step 2: Predict rendered output with default value
Since no prop is passed, name remains 'Friend', so the output is <h1>Hello, Friend!</h1>.
Final Answer:
<h1>Hello, Friend!</h1> -> Option A
Quick Check:
Default prop used = Hello, Friend! [OK]
Hint: Default props show if no value passed [OK]
Common Mistakes:
Assuming empty string if no prop
Expecting error for missing prop
Rendering literal {name} instead of value
4. Identify the error in this Astro component code:
A. The variable 'count' should be declared with 'export let' to update
B. The JSX arrow function syntax is invalid in Astro components
C. The event handler syntax should be 'on:click' instead of 'onClick' in Astro
D. Astro does not support buttons inside components
Solution
Step 1: Check event handler syntax in Astro
Astro uses 'on:event' syntax, so 'onClick' is incorrect and should be 'on:click'.
Step 2: Verify other code parts
Variable declaration is fine; arrow functions are allowed in event handlers; buttons are supported in Astro components.
Final Answer:
The event handler syntax should be 'on:click' instead of 'onClick' in Astro -> Option C
Quick Check:
Astro event syntax = on:event [OK]
Hint: Use 'on:click' not 'onClick' for events in Astro [OK]
Common Mistakes:
Using React-style 'onClick' instead of 'on:click'
Thinking variables must be exported to update
Believing Astro disallows buttons
5. You want to create a simple Astro page that shows a list of names passed as a prop and highlights names longer than 5 letters. Which approach fits best?
hard
A. Use React inside Astro and manage state with useState hook for the list
B. Use an Astro component with a <script> block to receive the list, then use a map in the markup with a condition to add a CSS class for long names
C. Write plain HTML with no scripting and manually highlight names
D. Create a server-side API to filter names before sending to Astro
Solution
Step 1: Understand Astro's component capabilities
Astro supports scripting inside components to receive props and render dynamic lists with conditions.
Step 2: Evaluate options for best fit
Using an Astro component with a <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.
Final Answer:
Use an Astro component with a <script> block to receive the list, then use a map in the markup with a condition to add a CSS class for long names -> Option B
Quick Check:
Astro dynamic list with condition = Use an Astro component with a <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]
Hint: Use Astro script + map + condition for dynamic lists [OK]
Common Mistakes:
Ignoring Astro's scripting and using static HTML
Adding React unnecessarily inside Astro
Overcomplicating with server APIs for simple UI
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.