Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions docs/svelte/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ If you wish to view the ideal SSR setup, please have a look at the [SSR example]
Together with SvelteKit's [`load`](https://kit.svelte.dev/docs/load), you can pass the data loaded server-side into `createQuery`'s' `initialData` option:

**src/routes/+page.ts**
```ts
import type { PageLoad } from './$types'

export const load: PageLoad = async () => {
```ts
export async function load() {
const posts = await getPosts()
return { posts }
}
```

**src/routes/+page.svelte**

```svelte
<script>
import { createQuery } from '@tanstack/svelte-query'
Expand Down Expand Up @@ -88,7 +88,7 @@ Svelte Query supports prefetching queries on the server. Using this setup below,
import { browser } from '$app/environment'
import { QueryClient } from '@tanstack/svelte-query'

export const load = async () => {
export async function load() {
const queryClient = new QueryClient({
defaultOptions: {
queries: {
Expand Down Expand Up @@ -119,9 +119,7 @@ export const load = async () => {
**src/routes/+page.ts**

```ts
import type { PageLoad } from './$types'

export const load: PageLoad = async ({ parent, fetch }) => {
export async function load({ parent, fetch }) {
const { queryClient } = await parent()

// You need to use the SvelteKit fetch function here
Expand Down