So far, we’ve dealt exclusively with internal state — that is to say, the values are only accessible within a given component.
In any real application, you’ll need to pass data from one component down to its children. To do that, we need to declare properties, generally shortened to ‘props’. In Svelte, we do that with the $props
rune. Edit the Nested.svelte
component:
Nested
<script>
let { answer } = $props();
</script>
previous next
<script>
import Nested from './Nested.svelte';
</script>
<Nested answer={42} />
loading svelte compiler