ibobdb.
Back to Articles

Optimizing Core Web Vitals in Next.js App Router

Engineering
1 min read

Understanding the App Router

The transition from the Pages Router to the App Router in Next.js represents a paradigm shift. By defaulting to React Server Components (RSC), we can drastically reduce the client-side JavaScript bundle.

Key Optimizations

  • Suspense Boundaries: Wrap slow data-fetching components in <Suspense> to unblock the initial page render.
  • Next/Image: Always use the native image component with proper sizes and priority attributes for LCP elements.
  • Font Optimization: Use next/font to automatically self-host fonts and eliminate Layout Shifts (CLS).

Code Example

import { Suspense } from 'react';
import { Skeleton } from '@/components/ui';

export default function Page() {
  return (
    <Suspense fallback={<Skeleton className="h-40" />}>
      <HeavyDataComponent />
    </Suspense>
  );
}

Conclusion

With careful architecture, achieving perfect Web Vitals is no longer a dark art, but a systematic application of Next.js primitives.