Why does __NEXT_DATA__
exists?
#15117
-
Can someone explain why the following element exists on my page: <script id="__NEXT_DATA__" type="application/json">
{
"props":{
"pageProps":{}
},
"page":"/",
"query":{},
"buildId":"mgml30LY3PGj-2IRzRxCf",
"runtimeConfig":{},
"nextExport":true,
"autoExport":true,
"isFallback":false
}
</script> I recently discovered that data fetching using This is not meant as a complaint, but as a question. I would like to understand why this is needed, and how I can optimize it for large data ( like fetching a lot of Markdown from a CMS ). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
That is used so Next (well, React) knows what data you want to hydrate on your page during server side rendering. Otherwise the server would not know what data to use to populate your React components. The page needs to get the data from somewhere and the DOM makes the most sense for any server rendered JavaScript application. |
Beta Was this translation helpful? Give feedback.
-
Hello. I use next js for a website with tabs from Material UI and just found out that only the first tab panel will be rendered as HTML. All the content that is in other tab panels is only visible as the props JSON in the NEXT_DATA script. What effects does that have on SEO? Does that negatively affect how easy it is for the google (& co.) crawlers to crawl the website? Thanks :D |
Beta Was this translation helpful? Give feedback.
That is used so Next (well, React) knows what data you want to hydrate on your page during server side rendering. Otherwise the server would not know what data to use to populate your React components. The page needs to get the data from somewhere and the DOM makes the most sense for any server rendered JavaScript application.