svelteserver-side-renderingsveltekit

With SvelteKit, in which file should I put the page options in?


According to the docs of page options here, it seems that prerender option could be put in either client files (namely +page.js and +layout.js) or server files (namely +page.server.js and +layout.server.js).

My questions are:

  1. In which file should I put the page options in? Or either client file or server file is OK?
  2. Are there any page option that can only be put in server/client files?

Solution

  • Not every route will have every possible file that can be associated with it. So I think the idea is that you can put the options into any of them so if you e.g. already are using +page.server.js you don't have to create a +page.js file just for the options.

    So I would recommend to put it an existing file or +page.js if you don't have any other loading/server code.

    (I am not aware of any limitations but they might exist.)