Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit f553361

Browse files
committed
examples(svelte): state serialization
1 parent 2e1316c commit f553361

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

starters/svelte/client/pages/index.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ export let getMeta = () => {
99
<script>
1010
import logo from '/assets/logo.svg'
1111
import { Link } from 'svelte-routing'
12+
import { isServer, useRouteContext } from '/dx:core.js'
13+
const { state } = useRouteContext()
14+
15+
if (isServer) {
16+
// Should be automatically hydrated on the client
17+
state.message = 'Welcome to Fastify DX for Svelte!'
18+
}
1219
</script>
1320

1421
<img src={logo} alt="Fastify DX" />
15-
<h1>Welcome to Fastify DX for Svelte!</h1>
22+
<h1>{state.message}</h1>
1623
<ul class="columns-2">
1724
<li><Link to="/using-data">/using-data</Link> demonstrates how to
1825
leverage the <code>getData()</code> function

0 commit comments

Comments
 (0)