This Astro page imports a Svelte component called ClickMe and shows it inside the page. The ClickMe component can have interactive behavior like a button that changes text when clicked.
Hint: Use default import with .svelte extension for Svelte components [OK]
Common Mistakes:
Using .js extension instead of .svelte
Using named import instead of default
Using CommonJS require() instead of import
3. Given this Astro code snippet, what will be rendered on the page?
---
import Counter from './Counter.svelte';
---
Assuming Counter.svelte shows the starting number inside a <p> tag.
medium
A.
0
B.
5
C. Error: start prop not recognized
D.
undefined
Solution
Step 1: Understand prop passing in Astro to Svelte
Props like start={5} are passed to Svelte components as expected.
Step 2: Check component behavior
The Counter component displays the start prop inside a paragraph, so it shows 5.
Final Answer:
<p>5</p> -> Option B
Quick Check:
Prop passed correctly = 5 shown [OK]
Hint: Props passed as attributes render inside component [OK]
Common Mistakes:
Assuming default 0 without checking prop
Thinking prop names must be strings
Expecting error without reason
4. What is wrong with this Astro code importing a Svelte component?
---
import MyButton from './MyButton.svelte'
---
medium
A. Missing semicolon after import statement
B. Svelte components cannot be used as tags in Astro
C. No error, code is correct
D. No closing tag for <MyButton>
Solution
Step 1: Check import syntax
Import statement is valid without semicolon; semicolons are optional in JavaScript/TypeScript.
Step 2: Check component usage
Svelte components can be used as tags in Astro with self-closing or paired tags; here paired tags are correct.
Final Answer:
No error, code is correct -> Option C
Quick Check:
Valid import and usage = No error, code is correct [OK]
Hint: Semicolons optional; Svelte components used as tags in Astro [OK]
Common Mistakes:
Thinking semicolon is mandatory
Believing Svelte components can't be used as tags
Confusing self-closing with paired tags
5. You want to add a Svelte component Toggle.svelte inside an Astro page that changes text on click. Which steps are needed to make it interactive inside Astro?
hard
A. Import the component, add client:load directive on the tag for hydration
B. Import the component, use it as a tag, and Astro handles hydration automatically
C. Write the component code inside Astro file without import
D. Use only Astro components; Svelte cannot be interactive in Astro
Solution
Step 1: Import and use Svelte component in Astro
Import Toggle.svelte and use it as a tag in Astro frontmatter and template.
Step 2: Enable hydration for interactivity
Add client:load or similar directive to tell Astro to hydrate the component on the client for interactivity.
Final Answer:
Import the component, add client:load directive on the tag for hydration -> Option A
Quick Check:
Hydration directive needed for interactivity [OK]
Hint: Add client:load to hydrate interactive Svelte components [OK]
Common Mistakes:
Assuming Astro auto-hydrates all components
Not adding hydration directive
Trying to write Svelte code inside Astro without import
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.