Learn component communication through props
Props are a way to pass data from a parent component to a child component. In Svelte 5, props are
declared using the $props() rune.
Here's how you define props in a child component with default values:
<script lang='ts'>
let { name = 'Thor' } = $props()
</script>
<p>Hello {name}!</p>When we pass the name prop, the component uses it:
Hello Svelte!
When no prop is passed, the default value ('Thor') is used:
Hello Thor!
Data flows from parent to child components
TypeScript ensures props are used correctly
Props can have fallback default values
Changes to props automatically update the UI