1

Im trying to build a website using nextjs. I thought it was a good pick for what im trying to do, but now im stuck.

I have a single api endpoint i want to call and fetch some static data. But the problem is that i need parts of the data all over my page - and what really seems to be the problem - all over my components.

For example i have <Navbar/> & <Sidebar/> Components that are conditionally rendered depending on screen size. Both need some of the data, but both are inside my <Layout/> Component.

Since getStaticProps can be only be exported from pages i have no idea how im supposed to get the data inside of these components.

From what i have learned i could use getStaticProps inside _app.js but with the downside that my pages can't be optimised anymore. But what does that mean? Whats the drawback doing that?

user3086509
  • 117
  • 1
  • 8
  • you want to pass that from the page to header and sidebar? what do u want to do exactly. your question is not clear – Yilmaz Mar 07 '21 at 12:59

0 Answers0