You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a library author of a lib that does server-side rendering using getInitialProps and would like to access pages' getServerSideProps
The way it works right now in my library:
Wrap _app default export with a HOC
Makes a prepass of the whole app tree to fetch underlying queries
Puts those queries in a cache once they're done
Renders page with a hydrated cache
When using getInitialProps in my _app.tsx I'd like to be able to resolve the page component's getServerSideProps in order to do combine a getInitialProps-call which does a prepass and renders the tree but that could also get the data that the specific page component has requested.
There might be a way of explicitly loading a component's getServerSideProps function in my library's root HOC that I add to the _app - maybe using something like loadComponents. Is there perhaps a way of doing that?
Extra notes
This all currently works with stale-while-revalidate edge-caching on Vercel - to see a reference project have a look at https://typescript.careers (source is in the footer)
This discussion was converted from issue #28182 on August 17, 2021 06:58.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Describe the feature you'd like to request
I'm a library author of a lib that does server-side rendering using
getInitialProps
and would like to access pages'getServerSideProps
The way it works right now in my library:
_app
default export with a HOCWhen using
getInitialProps
in my_app.tsx
I'd like to be able to resolve the page component'sgetServerSideProps
in order to do combine agetInitialProps
-call which does a prepass and renders the tree but that could also get the data that the specific page component has requested.Related issues that this would resolve:
@trpc/next
withssr: true
breaksgetServerSideProps
trpc/trpc#596 (my project)Describe the solution you'd like
It would be nice if
Was extended to something that contained the component's
GetServerSidePropsContext
-function, example:Describe alternatives you've considered
There might be a way of explicitly loading a component's
getServerSideProps
function in my library's root HOC that I add to the_app
- maybe using something likeloadComponents
. Is there perhaps a way of doing that?Extra notes
This all currently works with stale-while-revalidate edge-caching on Vercel - to see a reference project have a look at https://typescript.careers (source is in the footer)
Beta Was this translation helpful? Give feedback.
All reactions