Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR / SSG in SvelteKit for nested resources #689

Open
joepio opened this issue Jan 10, 2023 · 0 comments
Open

SSR / SSG in SvelteKit for nested resources #689

joepio opened this issue Jan 10, 2023 · 0 comments
Assignees
Labels
@tomic/svelte @tomic/svelte

Comments

@joepio
Copy link
Member

joepio commented Jan 10, 2023

We can use SvelteKit's load functions to wait for responses on a page, but not for a nested component. E.g. on a home page, the title will SSR just fine, but the articles will not be loaded yet.

The useResource hook returns undefined when the Resource hasn't been loaded yet. As a developer, you can use this to create loading states. However, SvelteKit doesn't seem to know that the page isn't done rendering.

So we need some way to do true static site generation / server side rendering for nested resources. I'm not entirely sure how, and I'm kind of a noob with Svelte(Kit), so here goes nothing:

Use svelte await blocks

https://svelte.dev/tutorial/await-blocks

I kind of assume these are implemented in SvelteKit in such a way that SSR / SSG waits until they render the non-loading state.

Load function that fetches N level nested resources

Instead of fetching just the requested page, also fetch it's relationships (e.g. fetch the author of a Post, fetch the articleList of a Blog).

Top level await

sveltejs/svelte#5501

Add a load function to these components

I'm not entirely sure if load functions are a thing for non-route components... But maybe they are.

@joepio joepio transferred this issue from atomicdata-dev/atomic-svelte Nov 6, 2023
@joepio joepio added the @tomic/svelte @tomic/svelte label Nov 6, 2023
joepio added a commit that referenced this issue Nov 20, 2023
joepio added a commit that referenced this issue Nov 20, 2023
joepio added a commit that referenced this issue Dec 5, 2023
joepio added a commit that referenced this issue Dec 5, 2023
joepio added a commit that referenced this issue Dec 5, 2023
joepio added a commit that referenced this issue Dec 5, 2023
joepio added a commit that referenced this issue Dec 7, 2023
joepio added a commit that referenced this issue Dec 7, 2023
joepio added a commit that referenced this issue Dec 7, 2023
joepio added a commit that referenced this issue Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@tomic/svelte @tomic/svelte
Projects
None yet
Development

No branches or pull requests

2 participants