-
Hi everyone! Been loving Svelte and SvelteKit. Using Django REST API as the backend. I should note right away that my site is completely auth/custom user content-free. The entire site is the same when viewed by anyone. My site is a catalog with a search function. So I use Django to manage the catalog/database and expose necessary objects/fields with the REST API. I've got my site created and deployed, and I'm very happy with it. My question is this: can I pre-render the data from the REST API for specific set of routes? And if yes, how do I "tell SvelteKit" about pre-defined values for parameterized pages (at most a single parameter)? My website has two major sections: the catalog and the search function. I don't expect the search to be pre-rendered at all because it's not possible to account for every permutation of search/filter state. However, when the search results come back, and the user clicks on an item, that page for the item very could easily be static. I also have directory pages listing every item/category, and those pages should be static as well. On the pages for each item, the header nav bar has a search field with auto complete, so I still do need to maintain that interactivity. I just don't want to make the API call to get the item's details when the user loads the page since there's a loading state. I understand there is SSR but I actually want to completely eliminate the request to my backend servers to vastly decrease their load. I will be able to export all necessary JSONs from the command line at build time for Svelte. Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
One idea I had was to use code generation templates (like Mako) to actually generate the exact pages that I want to make static as a pre-build step. I need to play around with |
Beta Was this translation helpful? Give feedback.
-
If you want to only prerender some pages, you need to use a different adapter. You will need to choose what host will be rendering the non-prerendered pages. You can can then prerender a single page with |
Beta Was this translation helpful? Give feedback.
If you want to only prerender some pages, you need to use a different adapter. You will need to choose what host will be rendering the non-prerendered pages. You can can then prerender a single page with
export const prerender = true
: https://kit.svelte.dev/docs/page-options#prerender