-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
Instead of doing the following (to prerender queries on the server):
// +page.ts
import { trpc } from '$lib/trpc/client';
import type { PageLoad } from './$types';
export const load: PageLoad = async (event) => {
const { queryClient } = await event.parent();
const api = trpc(event, queryClient);
return {
queries: await api.createServerQueries((t) => [
t.authed.todos.all(),
t.public.hello.get()
])
};
};
I'd like to be able to stream the result of queries
for example on my page. I'm new to Svelte, but I know that Svelte does support streaming data via promises. Apparently if you don't await the data in the server load function, you can use the await
block on the client to show a loading fallback while the promise resolves.
For example (From: https://kit.svelte.dev/docs/load#streaming-with-promises):
// +page.svelte.ts
{#await data.streamed.comments}
Loading...
{:then value}
{value}
{/await}
In relation to createServerQueries
, is there a way I can do streaming with it, so I can have faster page loads? Any advice/guidance would be super appreciated!
Metadata
Metadata
Assignees
Labels
No labels