question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.)

See original GitHub issue

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()).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, May 3, 2021

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.

1reaction
deckchairlabscommented, May 3, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

A set of utility functions and types to use with Remix.run - GitHub
This function is an object version of Promise.all which lets you pass an object with promises ... This part of Remix Utils needs...
Read more >
How to handle not found 404 for dynamic routes in Next.js ...
A way to get a real "HTTP 404" response understood by GoogleBot is to generate the 404 server side. First, write a default...
Read more >
State Management In Next.js - Smashing Magazine
Using the server-side methods for generating content statically is often preferable to fetching the state from the client-side. The Context API ...
Read more >
Blog - Next.js 13
Next.js 13 introduces layouts, React Server Components, and streaming in the app directory, as well as Turbopack, an improved image ...
Read more >
The Next.js Handbook – Learn Next.js for Beginners
It provides a common structure that allows you to easily build a frontend React application, and transparently handles server-side rendering for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found