Global element and headless #12162
-
Hello, I am trying to figure out what is the best way to not make a call for header (Main navigation) and Footer on every route change. The data is the same across the entire site. I can't seem to wrap my head around making it persist and not rerender the header and footer every time. Is there a built in set up with in next to make that happen? Or do I need to have that data stored in like context and make the call just once as soon as the user enter the site? Any input would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Could you share an example? Based on your question, this is what I'm hearing:
Could you try: |
Beta Was this translation helpful? Give feedback.
-
@leerob - Yeah you got all my points mentioned above correct. As it currently stand: I am making a getServerSideProps which will get two endpoints (header/footer data, and the page data) in the [...index].jsx file, this function runs every page route change. Base from what you mentioned moving the header and footer component and api call to _app.js, do I use getServersideprops function in there so that it makes the call only one time? I would provide an example but the code and data I am using is all confidential :/ |
Beta Was this translation helpful? Give feedback.
@leerob - Yeah you got all my points mentioned above correct.
As it currently stand:
I am making a getServerSideProps which will get two endpoints (header/footer data, and the page data) in the [...index].jsx file, this function runs every page route change.
Base from what you mentioned moving the header and footer component and api call to _app.js, do I use getServersideprops function in there so that it makes the call only one time?
I would provide an example but the code and data I am using is all confidential :/