Replies: 2 comments 5 replies
-
There's multiple ways you can tackle this, but generally, anywhere before you actually render your page. So somewhere in your If you don't need your navigation data from the API to be available during runtime (if getting this information during build-time is enough), you should consider using getStaticProps. Even more wonderful is getStaticPaths, which allows you to statically generate your entire website at build-time based on that API. This is only useful though if that information is available at build-time and doesn't need to change until you build again, then again, if it only sometimes changes on some pages, you can consider using Incremental Builds. If you need your navigation data from that API endpoint to be available with server-side rending, you should consider: getServerSideProps instead of getInitialProps. getInitialProps might run twice on front-end and back-end and if you only need it for SSR, use getServerSideProps, down-side is that you'll lose static optimalisation using this in _app. I recommend properly reading the Data Fetching docs before you make a decision! |
Beta Was this translation helpful? Give feedback.
-
[email protected] version, other pages use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an application which gets its Navigation from and API Endpoint. This Navigation is visible on every page. What do you think is the best way to fetch this navigation from the API. Currently I have it in the _app in the getInitialProps but this is not the best option I think! Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions