I have a SvelteKit/Tauri project which all needs to be prerendered as it will be a desktop application. In my SvelteKit project, i have the following routing, which contains a slug:
/edit/calculator/[calculator_id]
The slug parameter is an id
used to querying the calculator with the given id
and then display the calculators properties. I do not know the calculator_id
parameters in my embedded database beforehand, which makes the routes unknown at compile/build time.
When building the project, i get the following error:
node:internal/event_target:1033
process.nextTick(() => { throw err; });
^
Error: The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:
- /edit/calculator/[calculator_id]
See https://kit.svelte.dev/docs/page-options#prerender-troubleshooting for info on how to solve this
at prerender (file:///C:/Users/ono/Documents/Programmering/versa-flow/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:475:9)
at async MessagePort.<anonymous> (file:///C:/Users/ono/Documents/Programmering/versa-flow/node_modules/@sveltejs/kit/src/utils/fork.js:22:16)
Emitted 'error' event on Worker instance at:
at [kOnErrorMessage] (node:internal/worker:300:10)
at [kOnMessage] (node:internal/worker:311:37)
at MessagePort.<anonymous> (node:internal/worker:212:57)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:757:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28)
I have tried to look into the documentation mentioned in the error message, it talks about specifying specific pages as prerenderable, but i do not understand it properly and know how to fix this issue by reading the docs.
The explanation states that dynamic parameters can be pre-rendered only if there are links to said route with specific parameter values. You cannot pre-render a dynamic route if the parameter values are not known.
In other words, you cannot possibly pre-render all possible combinations of URL's that are possible. You can list explicit cases in the entries
option as stated in the document, or forget about pre-rendering.
Summarizing: You cannot pre-render without first assigning values to the route parameters.