Next.js Discord

Discord Forum

Global getServerSideProps for navigation

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Goals:
✅ get data from contentful
✅ render nav items from data

🤔 get data on server side

the last part has me stuck and chatGTP is going round in circles.

Is it possible to getServerSideProps to render my nav items on server side without having to make the getServerSideProps request on every page?

7 Replies

Brown bearOP
how about as a solution
if user (aka Google) hit home page we have SSR nav items
if user hits any subsequent page the same data is used
if user lands on page and no SSR data is there we client side fetch the data


i was hoping there would be a more graceful solution than this 😅
Asian black bear
You are basically wishing for and describing the /app router with layout.ts files
Brown bearOP
yes chatGPT kept telling me this... we want to move to app directory but it wont happen today... i wonder is it possible to mix and match, render my header on app/layout then my pages from /pages
Asian black bear
no, they are absolutely completely separate react instances
with ISR and getStaticProps on the non-server-side pages you can kind of mitigate the badness of it
Brown bearOP
thanks for the feedback, in the end i went for CSR and will measure if Google can index before i take an radical steps 😅
Brown bearOP
sorry for the late reply, i went AFK for my birthday 😅