react-doctor/nextjs-missing-metadata
Add `export const metadata = { title: '...', description: '...' }` or `export async function generateMetadata()`
- Category: Next.js
- Severity: warn
- 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 on App Router pages (files matching /page.{tsx,jsx,ts,js}) that don't export a top-level metadata constant, generateMetadata function, or generateMetadata variable. The rule skips routes likely behind auth (paths or route groups named dashboard, admin, settings, account, internal, manage, console, portal, auth, onboarding, app, ee, protected) where SEO doesn't matter. Pages Router files are not checked.
Fix prompt
Use this once validation confirms the diagnostic is real.
Add export const metadata: Metadata = { title: '...', description: '...' } (import Metadata from 'next'), or export async function generateMetadata({ params }) for dynamic data. Metadata declared in a parent layout.tsx is inherited and also satisfies the rule. https://nextjs.org/docs/app/api-reference/functions/generate-metadata
Related rules
More Next.js rules from the rules reference:
react-doctor/nextjs-no-a-element: `import Link from 'next/link'` — enables client-side navigation, prefetching, and preserves scroll positionreact-doctor/nextjs-no-client-fetch-for-server-data: Remove 'use client' and fetch directly in the Server Component — no API round-trip, secrets stay on serverreact-doctor/nextjs-no-client-side-redirect: Avoid redirects inside useEffect. Use an event handler, middleware, or server-side redirect (App Router: redirect() from next/navigation; Pages Router: getServerSideProps redirect)react-doctor/nextjs-no-css-link: Import CSS directly: `import './styles.css'` or use CSS Modules: `import styles from './Button.module.css'`react-doctor/nextjs-no-default-export-in-route-handler: Remove the default export from this route.ts and export the handler as a named HTTP method instead: export async function GET(request: Request) { ... }