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) { ... }
- Category: Bugs
- Severity: error
- Source:
oxlint-plugin-react-doctor - Framework: nextjs
- Enabled when: framework=nextjs and capabilities=nextjs
- Tags: test-noise
- Default: Enabled
- Documentation: https://nextjs.org/docs/app/api-reference/file-conventions/route
Validate the diagnostic
Confirm the reported code matches this rule before you edit it.
Fires only when the file path matches both APP_DIRECTORY_PATTERN (/app/) and ROUTE_HANDLER_FILE_PATTERN (/route.{ts,tsx,js,jsx,mts,mjs}), and the file has either an ExportDefaultDeclaration (export default ...) or an ExportNamedDeclaration whose specifier is exported as default (export { handler as default }) — AND the program does NOT already export a named HTTP method. The suppressing check programHasNamedHttpMethodExport scans for any export named GET/POST/PUT/PATCH/DELETE/OPTIONS/HEAD via a named function declaration, a variable declaration, or an export specifier, so a default export coexisting with a real named method export will not fire. False positive: confirm only if no named HTTP method export exists in the SAME file — if the route already exports e.g. GET or POST as a named symbol the default export is dead but harmless and is correctly not flagged; also suppress for any file not actually named route.* under app/ (a pages/ API route, a non-route module, or a barrel/re-export file that is not itself the route handler), since the gate is purely the filename and never the file's location relative to a route.
How to fix
Follow the rule guidance while preserving unrelated behavior.
Copyable fix prompt
Copy this self-contained prompt into your coding agent after you confirm the diagnostic.
Related rules
More Bugs rules from the rules reference:
react-doctor/nextjs-no-edge-og-runtime: Remove `export const runtime = "edge"` from OG image route files so they use the default Node.js runtimereact-doctor/nextjs-no-font-link: `import { Inter } from "next/font/google"` — self-hosted, zero layout shift, no render-blocking requestsreact-doctor/nextjs-no-google-analytics-script: Replace manual GA script with the optimized component: import { GoogleAnalytics } from '@next/third-parties/google'react-doctor/nextjs-no-head-import: Use the Metadata API instead: `export const metadata = { title: '...' }` or `export async function generateMetadata()`react-doctor/nextjs-no-img-element: `import Image from 'next/image'` — provides automatic WebP/AVIF, lazy loading, and responsive srcset