Skip to main content

We can easily specify default values for props in Nested.svelte:

Nested
<script>
	let { answer = 'a mystery' } = $props();
</script>

If we now add a second component without an answer prop, it will fall back to the default:

App
<Nested answer={42}/>
<Nested />

Edit this page on GitHub

1
2
3
4
5
6
<script>
	import Nested from './Nested.svelte';
</script>
 
<Nested answer={42} />