nextjs - 💡(How to fix) Fix duplicate structured data when using dangerouslySetInnerHTML [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85956Fetched 2026-04-08 02:13:14
View on GitHub
Comments
2
Participants
3
Timeline
7
Reactions
0
Author
Timeline (top)
commented ×2labeled ×2closed ×1issue_type_added ×1

Code Example

operating system: 
  macbook air m2
binaries:
   node: v20.19.4
   pnpm: v10.x
relative packages:
   "react": "19.1.0",
   "react-dom": "19.1.0",
   "next": "15.3.0",
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/IsKaros/duplicate-structured-data

To Reproduce

1.first enter the page using dangerouslySetInnerHTML to generate structured data 2.refresh the page 3.open the element tab or using plugins to see the structured data

<img width="1892" height="1256" alt="Image" src="https://github.com/user-attachments/assets/798bf023-0542-4ad7-9dab-8f3e8d758767" />

haven't anyone see the problem before ? Is there any solution to solve the problem without break the seo

Current vs. Expected behavior

current: duplicate structured data after first rendering expected: without duplicate structured data

Provide environment information

operating system: 
  macbook air m2
binaries:
   node: v20.19.4
   pnpm: v10.x
relative packages:
   "react": "19.1.0",
   "react-dom": "19.1.0",
   "next": "15.3.0",

Which area(s) are affected? (Select all that apply)

Loading UI and Streaming

Which stage(s) are affected? (Select all that apply)

next dev (local), Other (Deployed)

Additional context

No response

extent analysis

TL;DR

  • The issue can likely be mitigated by ensuring that dangerouslySetInnerHTML is used judiciously and that the structured data is properly sanitized and updated to prevent duplication.

Guidance

  • Review the usage of dangerouslySetInnerHTML to ensure it's necessary and used correctly, as it can lead to unexpected behavior, including the duplication of structured data.
  • Verify that the structured data is being updated correctly on page refresh and when inspecting the element tab or using plugins, to identify if the issue is related to how the data is being rendered or updated.
  • Consider implementing a mechanism to sanitize and deduplicate the structured data before it's rendered, to prevent SEO issues and ensure the expected behavior.
  • Inspect the network requests and responses to see if the duplicate structured data is being sent from the server or if it's a client-side issue, to determine the best approach for fixing the problem.

Example

No specific code example can be provided without more context on how dangerouslySetInnerHTML is being used, but ensuring that the content is sanitized and that any scripts or data within it are handled correctly is crucial.

Notes

The provided information lacks specific details on how dangerouslySetInnerHTML is implemented and how the structured data is generated and updated, making it challenging to provide a precise solution. The issue might be related to how Next.js handles server-side rendering (SSR) and static site generation (SSG), and how React updates the DOM.

Recommendation

  • Apply workaround: Implementing a sanitization and deduplication mechanism for the structured data seems like the most feasible approach given the current information, as it directly addresses the issue of duplicate data without requiring significant changes to the underlying infrastructure or dependencies.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix duplicate structured data when using dangerouslySetInnerHTML [2 comments, 3 participants]