# inline-script-id

Rule `nextjs/inline-script-id`. Enforce `id` attribute on `next/script` components with inline content.

- Source: nextjs
- Technologies: Next.js, React
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 130.3M weekly downloads of presets that enable it
- Trend: +60.5% last quarter
- Rank: #129 by reach, #709 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@next/next/inline-script-id` | yes | no | package `@next/eslint-plugin-next` | [docs](https://nextjs.org/docs/messages/inline-script-id) |
| Oxlint | `nextjs/inline-script-id` | no | no | plugin `nextjs`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/nextjs/inline-script-id.html) |
| Biome | `correctness/useInlineScriptId` | yes | no | group correctness, since 2.3.12 | [docs](https://biomejs.dev/linter/rules/use-inline-script-id/) |

## Code examples

### Incorrect: the rule reports this

```js
import Script from 'next/script';

export default function Page() {
  return (
    <Script>
      {`console.log('Hello world');`}
    </Script>
  );
}

// Also incorrect with dangerouslySetInnerHTML
export default function Page() {
  return (
    <Script
      dangerouslySetInnerHTML={{
        __html: `console.log('Hello world');`
      }}
    />
  );
}
```

### Correct: the rule accepts this

```js
import Script from 'next/script';

export default function Page() {
  return (
    <Script id="my-script">
      {`console.log('Hello world');`}
    </Script>
  );
}

// Correct with dangerouslySetInnerHTML
export default function Page() {
  return (
    <Script
      id="my-script"
      dangerouslySetInnerHTML={{
        __html: `console.log('Hello world');`
      }}
    />
  );
}

// No id required for external scripts
export default function Page() {
  return (
    <Script src="https://example.com/script.js" />
  );
}
```

Examples from the Oxlint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import next from "@next/eslint-plugin-next";

export default [
  {
    plugins: { "@next/next": next },
    rules: {
      "@next/next/inline-script-id": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "nextjs"
  ],
  "rules": {
    "nextjs/inline-script-id": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "useInlineScriptId": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Next.js recommended](https://lintradar.dev/presets/next-recommended.md) | ESLint | `@next/eslint-plugin-next` | 22 | 52.9M | +50.7% |
| [Next.js Core Web Vitals](https://lintradar.dev/presets/next-core-web-vitals.md) | ESLint | `eslint-config-next` | 62 | 46.8M | +48.8% |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |

## Related rules

- [nextjs/google-font-preconnect](https://lintradar.dev/rules/nextjs/google-font-preconnect.md): Ensure `preconnect` is used with Google Fonts.
- [nextjs/no-document-import-in-page](https://lintradar.dev/rules/nextjs/no-document-import-in-page.md): Prevent importing `next/document` outside of `pages/_document.js`.
- [nextjs/google-font-display](https://lintradar.dev/rules/nextjs/google-font-display.md): Enforce font-display behavior with Google Fonts.
- [nextjs/no-head-element](https://lintradar.dev/rules/nextjs/no-head-element.md): Prevent usage of `<head>` element.
- [nextjs/no-head-import-in-document](https://lintradar.dev/rules/nextjs/no-head-import-in-document.md): Prevent usage of `next/head` in `pages/_document.js`.
- [nextjs/no-img-element](https://lintradar.dev/rules/nextjs/no-img-element.md): Prevent usage of `<img>` element due to slower LCP and higher bandwidth.

---

Web page: https://lintradar.dev/rules/nextjs/inline-script-id. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
