Rules
nextjs-no-img-element
nextjs-no-img-element
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-img-elementRequires using next/image instead of plain <img> tags for automatic optimization.Why itβs bad:- No automatic optimization
- No lazy loading by default
- No responsive srcset generation
- Larger cumulative layout shift
This rule is disabled in OG image routes (
/app/og/route.tsx) where you need raw <img> for OpenGraph image generation.nextjs-async-client-component
nextjs-async-client-component
Severity: error
Rule ID:Good:
Rule ID:
react-doctor/nextjs-async-client-componentPrevents marking client components as async. Client components cannot be async functions.Bad:nextjs-no-a-element
nextjs-no-a-element
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-a-elementRequires using next/link for internal navigation to enable client-side routing and prefetching.Bad:nextjs-no-use-search-params-without-suspense
nextjs-no-use-search-params-without-suspense
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-use-search-params-without-suspenseRequires wrapping useSearchParams() in a Suspense boundary to prevent the entire page from falling back to client-side rendering.Why itβs bad:- Entire page renders on client instead of server
- Slower initial page load
- Loses benefits of server components
nextjs-no-client-fetch-for-server-data
nextjs-no-client-fetch-for-server-data
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-client-fetch-for-server-dataPrevents using useEffect + fetch in page/layout files. Data should be fetched server-side.Bad:nextjs-missing-metadata
nextjs-missing-metadata
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-missing-metadataRequires page files to export metadata or generateMetadata for SEO.Bad:This rule ignores internal routes like
/app/(dashboard)/, /app/admin/, etc.nextjs-no-client-side-redirect
nextjs-no-client-side-redirect
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-client-side-redirectSuggests using redirect() in server components or middleware instead of client-side redirects.Bad:nextjs-no-redirect-in-try-catch
nextjs-no-redirect-in-try-catch
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-redirect-in-try-catchPrevents calling redirect() inside try-catch blocks. redirect() throws a special error that Next.js handles internally.Bad:nextjs-image-missing-sizes
nextjs-image-missing-sizes
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-image-missing-sizesRequires sizes attribute on images with fill prop for responsive behavior.Bad:nextjs-no-native-script
nextjs-no-native-script
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-native-scriptRequires using next/script instead of plain <script> for loading strategy optimization.Bad:nextjs-inline-script-missing-id
nextjs-inline-script-missing-id
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-inline-script-missing-idRequires id attribute on inline <Script> components for Next.js tracking.Bad:nextjs-no-font-link
nextjs-no-font-link
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-font-linkRequires using next/font instead of Google Fonts CDN for self-hosting and zero layout shift.Bad:nextjs-no-css-link
nextjs-no-css-link
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-css-linkSuggests importing CSS directly instead of using <link> tags for bundling and optimization.Bad:nextjs-no-polyfill-script
nextjs-no-polyfill-script
Severity: warn
Rule ID:Good:
Remove the script - Next.js handles polyfills automatically.
Rule ID:
react-doctor/nextjs-no-polyfill-scriptNext.js includes automatic polyfills for modern JavaScript features. External polyfill scripts are unnecessary.Bad:nextjs-no-head-import
nextjs-no-head-import
Severity: error
Rule ID:Good:
Rule ID:
react-doctor/nextjs-no-head-importnext/head is not supported in the App Router. Use the Metadata API instead.Bad:nextjs-no-side-effect-in-get-handler
nextjs-no-side-effect-in-get-handler
Severity: error
Rule ID:Good:Side effects detected:
Rule ID:
react-doctor/nextjs-no-side-effect-in-get-handlerPrevents side effects in GET route handlers to prevent CSRF and unintended prefetch triggers.Why itβs bad:- GET requests should be safe (no side effects)
- Next.js prefetches routes automatically
- CSRF attacks can trigger GET requests
- Database writes (insert, update, delete)
- User logout/signout in route path
- State mutations
Server vs Client Components
Next.js App Router uses server components by default:When to use client components:
- Event handlers (onClick, onChange)
- React hooks (useState, useEffect)
- Browser APIs
- Third-party interactive components
When to use server components:
- Data fetching
- Direct database access
- Server-only code
- Reducing bundle size
Related Rules
- Performance Rules - General React performance
- Bundle Size Rules - Code splitting strategies
- Security Rules - Security best practices