Optimizing Menu Data Fetching in Next.js and WordPress: Building Efficiency into Header Components
Unanswered
Argente Brun posted this in #help-forum
Argente BrunOP
I'm currently working with Next.js and WordPress. I've created a layout component that wraps my pages, containing header, children, and footer sections. In the header component, I need to fetch menu data using a static query. However, getStaticProps() only works in pages, not in components like the header.
I want to avoid calling the menu query on every page and passing it from parent to child components. Is there a way to execute a query in the header at build time, ensuring the menu data is available globally without runtime fetching on each page?
Also I am using Pages Router.
Your assistance in resolving this matter would be greatly appreciated.
I want to avoid calling the menu query on every page and passing it from parent to child components. Is there a way to execute a query in the header at build time, ensuring the menu data is available globally without runtime fetching on each page?
Also I am using Pages Router.
Your assistance in resolving this matter would be greatly appreciated.