0
0
Astroframework~5 mins

Svelte components in Astro - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of using Svelte components inside an Astro project?
Svelte components let you build interactive parts of your website with a simple, reactive framework, while Astro handles the overall page structure and static content efficiently.
Click to reveal answer
beginner
How do you import a Svelte component into an Astro file?
Use the syntax: <code>import ComponentName from './ComponentName.svelte';</code> at the top of your Astro file.
Click to reveal answer
beginner
How do you include a Svelte component in the Astro page template?
After importing, use the component as a tag like <ComponentName /> inside the Astro file's HTML section.
Click to reveal answer
intermediate
What is a key benefit of using Svelte components in Astro compared to plain HTML?
Svelte components provide reactivity and interactivity with less code and better performance, while Astro optimizes loading by only sending needed JavaScript.
Click to reveal answer
intermediate
Can you pass props to a Svelte component inside Astro? How?
Yes, pass props like HTML attributes: <ComponentName prop1="value" />. The Svelte component receives them as usual props.
Click to reveal answer
How do you add a Svelte component to an Astro page?
AConvert Svelte to HTML manually before use
BWrite Svelte code directly inside Astro without import
CUse a special Astro directive without import
DImport it and use it as a tag in the Astro file
What file extension do Svelte components use?
A.svelte
B.astro
C.jsx
D.vue
Which of these is a benefit of using Svelte components in Astro?
AThey require no JavaScript at all
BThey make the whole site static with no interactivity
CThey allow reactive UI with minimal JavaScript sent to the browser
DThey replace Astro's HTML rendering
How do you pass data to a Svelte component in Astro?
AUsing HTML attributes on the component tag
BUsing global variables only
CYou cannot pass data to Svelte components in Astro
DBy editing the Svelte file directly
What happens if you don't import a Svelte component before using it in Astro?
AAstro automatically finds and imports it
BYou get a build error because the component is unknown
CThe component renders as plain HTML
DThe component works but without interactivity
Explain how to use a Svelte component inside an Astro page from import to rendering.
Think about how you bring a component in and then place it in the page.
You got /3 concepts.
    Describe the benefits of combining Svelte components with Astro for building websites.
    Consider what each tool does best and how they work together.
    You got /4 concepts.