react-doctor/nextjs-no-head-import
Use the Metadata API instead: `export const metadata = { title: '...' }` or `export async function generateMetadata()`
- Category: Next.js
- Severity: error
- Source:
oxlint-plugin-react-doctor - Framework: nextjs
- Enabled when: framework=nextjs and capabilities=nextjs
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Triggers only when import ... from 'next/head' appears in a file whose path contains /app/. Pages Router files (under /pages/) may legitimately use next/head and are not flagged. False positive if /app/ appears coincidentally in a path that isn't actually the App Router (e.g. a monorepo named 'app').
Fix prompt
Use this once validation confirms the diagnostic is real.
Delete the next/head import and <Head> JSX. Export metadata (static) or generateMetadata (dynamic) from the page or layout. Use file conventions like icon.tsx, opengraph-image.tsx, robots.ts, and sitemap.ts for non-meta tags; return arbitrary <meta> via generateMetadata. https://nextjs.org/docs/app/getting-started/metadata-and-og-images
Related rules
More Next.js rules from the rules reference:
react-doctor/nextjs-no-img-element: `import Image from 'next/image'` — provides automatic WebP/AVIF, lazy loading, and responsive srcsetreact-doctor/nextjs-no-native-script: `import Script from "next/script"` — use `strategy="afterInteractive"` for analytics or `"lazyOnload"` for widgetsreact-doctor/nextjs-no-polyfill-script: Next.js includes polyfills for fetch, Promise, Object.assign, Array.from, and 50+ others automaticallyreact-doctor/nextjs-no-redirect-in-try-catch: Move the redirect/notFound call outside the try block, or add `unstable_rethrow(error)` in the catchreact-doctor/nextjs-no-script-in-head: Move <Script> out of <Head>: next/script ignores head placement, so a Script nested in Head silently never loads