Basic Svelte
Introduction
Bindings
Advanced Svelte
Advanced reactivity
Motion
Advanced bindings
Advanced transitions
Context API
Special elements
<script module>
Next steps
Basic SvelteKit
Introduction
Routing
Loading data
Headers and cookies
Shared modules
API routes
$app/state
Errors and redirects
Advanced SvelteKit
Page options
Link options
Advanced routing
Advanced loading
Environment variables
Conclusion
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>
<script lang="ts">
let { answer } = $props();
</script>
previous next
1
2
3
4
5
6
<script>
import Nested from './Nested.svelte';
</script>
<Nested answer={42} />