next.jsnext.js13browser-history

what is __PRIVATE_NEXTJS_INTERNALS_TREE for?


While using History API on Next.js project, I found a data called '__PRIVATE_NEXTJS_INTERNALS_TREE' in state field of history object.

To find out what exactly this field for, I tried to search from official docs of Next.js, google on Stack Overflow, search on Next.js GitHub issue tabs, but found nothing related.

What is this data exactly for?

enter image description here

to reproduce, follow below code

// any next.js project

console.log(window.history.state)
  1. Reading Offical Documents
  2. Search for articles from stack overflow
  3. look up on Next.js github issue tabs

Expecting what __PRIVATE_NEXTJS_INTERNALS_TREE is for.


Solution

  • This data represents the history of the previous page URL. For example, if you are on page name cars(can also have the parameters). And then you click on a link and go to any new page. On the new page, you can get the URL of the previous page. And this tree __PRIVATE_NEXTJS_INTERNALS_TREE saves the data of the previous URL. enter image description here