-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have an option of exposing __NEXT_DATA during static export. #5903
Comments
Based on your description you can already do this. You can use |
Thanks for providing that link, it was very helpful in showing how |
@timneutkens Are you able to elaborate? @EnMod Have you found a solution using an example provided above? |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Feature request
Is your feature request related to a problem? Please describe.
One of the main reasons of creating a static build is that the website won't hit any data APIs and will run as a static website. While this can be possible by just having anchor tags instead of links, the disadvantage here is the handling of component states using state management tools like Redux or Mobx. If there is a way to save the data of getInitialProps as JSON, it would be extremely useful to bypass the data API call and still maintain the component state as a SPA.
Describe the solution you'd like
During export, have an option of exposing the data received from getInitialProps. Then, the user can use this prop data in his/her own way inside the page components. If someone wants to keep the API calls in pages, they can ignore the exposed data. I noticed that we can get the props data from the render.js file inside the dist/server folder. If we can expose that data in next.config via a function during export, it'd be great!
Describe alternatives you've considered
As of now, I don't see any other alternatives on this.
I think this feature would really improve Next and give the users a flexibility of developing their apps.
The text was updated successfully, but these errors were encountered: