Search code examples
javascriptreactjsnext.jsserver-side-rendering

Next JS - SSR with nested component


I need to create navigation in Layout with data from API and display it on certain pages.

Layout is not in the pages folder, I can't use the getStaticProps and getServerSideProps methods. At the same time, I would like the navigation to be created on the server side and be immediately on the page for SEO.

Now I'm getting data using the getStaticProps method on pages where this navigation is needed, and everything works, but the navigation component is loaded additionally.

Couldn't find an answer anywhere on how to do this. There must be some option... Thanx.


Solution

  • Instead of getting categories from pageProps in _app.js, I called useEfefct, changed it to pageProps, now everything is fine.