Sign inTry it

__NEXT_DATA__

__NEXT_DATA__ is a script tag with that ID on sites built with the Next.js Pages Router. It holds the page props that the server computed for the page, as JSON. A tool can read this structured data instead of parsing the page layout.

Updated

How it works

With getServerSideProps, the server computes props for each request and passes them to the page component. The Pages Router writes those props into the HTML inside script#__NEXT_DATA__. The browser reuses them when it starts the page, so the page does not fetch the same data again.

Reading it

  1. Load the page HTML.
  2. Select the script#__NEXT_DATA__ element.
  3. Read its text and parse it as JSON.
  4. Pick the fields you need. Next.js stores the page props under a props key.

Why it matters for AI agents

The tag gives tools one predictable place to read structured data, which is easier than matching the page layout. The position of the data can survive a redesign. The data's shape can still change when the site changes its code.

Wield and __NEXT_DATA__

The Wield recipe format extracts values from HTML with CSS selectors. Its docs use script#__NEXT_DATA__ as an example selector. Recipes can then map fields from the parsed JSON.

FAQ

Does the App Router have __NEXT_DATA__?

This tag belongs to the Pages Router. If a site runs on the App Router, do not assume the tag exists. Check the page source first, and look for the data elsewhere.

How can I read __NEXT_DATA__?

Load the page HTML, select script#__NEXT_DATA__, read the element's text, and parse that text as JSON. The props sit under the props key of the parsed object.

Sources

  1. Next.js: getServerSidePropsnextjs.org