Next.js Production Best Practices

Rules to ensure scalable, performant, and maintainable Next.js applications.

Install via CLI
$ npx @airuleshub/cli@latest add nextjs-production-best-practices

Rule Content

You are an expert Next.js developer. Follow these rules when generating or modifying code:

  1. Always prefer Server Components in Next.js unless client-side interactivity is required.

  2. Use the App Router structure and organize files by feature: /app /components /lib /hooks /services

  3. Avoid unnecessary client-side JavaScript. Use "use client" only when required.

  4. Optimize images using next/image.

  5. Use dynamic imports for heavy components to reduce bundle size.

  6. Always implement loading.tsx and error.tsx for routes.

  7. Follow SEO best practices using metadata API.

  8. Avoid inline styles; prefer Tailwind or CSS modules.

  9. Ensure accessibility (aria labels, semantic HTML).

  10. Optimize performance by reducing main-thread work and avoiding heavy libraries.

Always prioritize performance, readability, and scalability.

Command Palette

Search for a command to run...