vike: Allow `addContextProps()` to be called on the client-side. (For page transitions that happen 100% in the client and where the server is not invovled at all.)

Currently addContextProps() is defined in .page.server.js and always called in Node.js which is an important invariant for people who use SQL/ORM queries in their addContextProps() functions.

This ticket is about enabling addContextProps() to be called in the browser by defining it in .page.js instead of .page.server.js. It would still always be called in Node.js when rendering a page to HTML, but for any susequent page navigation addContextProps() would be called in the browser (when using useClientRouter()).

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (16 by maintainers)

Most upvoted comments

I do like the idea of keeping everything in as few files as possible, but I think having addContextProps be called with different contexts would be confusing, that’s what originally confused me w/ the route file.

This ticket is actually about addressing this. Currently addContextProps() is defined in .page.server.js and always called in Node.js which is an important invariant for people who use SQL/ORM queries in their addContextProps() functions. This ticket is about enabling addContextProps() to be called in the browser by defining it in .page.js instead of .page.server.js.

confusing, that’s what originally confused me

Clarifying things is a top priority. Proper documentation will go in a long way in clearing things out.

Yeah, being able to define everything in *.page.ts files would be so great. When I stumbled across this project my immediate thought was “I could make a clone of Remix with this” https://remix.run/ I really like the clean API they have https://www.youtube.com/watch?v=4dOAFJUOi-s&t=1281s