Skip to content

Files

Latest commit

 

History

History
22 lines (16 loc) · 504 Bytes

inline-script-id.md

File metadata and controls

22 lines (16 loc) · 504 Bytes

Pattern: Missing script id

Issue: -

Description

Next.js requires inline scripts to have an id attribute for proper hydration. Without an id, inline scripts may not execute correctly during server-side rendering and client-side hydration.

Examples

Example of incorrect code:

<script dangerouslySetInnerHTML={{ __html: `console.log('hello')` }} />

Example of correct code:

<script 
  id="my-script"
  dangerouslySetInnerHTML={{ __html: `console.log('hello')` }}
/>