Make Your Next.js App Faster
Image optimization, code splitting, and caching strategies. The stuff that actually moves the needle.
Fast Apps Keep Users Around
Every second of load time costs you visitors. Research from Google shows that as page load goes from 1 to 3 seconds, bounce probability increases by 32%. At 5 seconds, it jumps to 90%.
AI-built Next.js apps start fast, but they can slow down as you add features. Here is how to keep them quick.
Images Are Usually the Biggest Problem
Images account for most of the bytes on a typical web page. Next.js has a built-in Image component that handles optimization automatically.
Replace every <img> tag with <Image> from next/image. It:
- Serves WebP or AVIF formats automatically
- Lazy loads images below the fold
- Generates responsive sizes for different screens
- Caches optimized versions
If you are using an AI builder, ask: "Replace all img tags with the Next.js Image component and add proper width and height values."
Code Splitting and Dynamic Imports
Next.js splits your code by route automatically. But if you import a heavy library on every page, it defeats the purpose.
Use dynamic imports for anything that is not needed on first render:
const HeavyChart = dynamic(() => import('./Chart'), {
loading: () => <Skeleton />,
ssr: false,
})
Good candidates for dynamic imports: charts, rich text editors, maps, PDF viewers.
Reduce Client-Side API Calls
Every API call on page load adds to perceived latency. Move data fetching to the server where possible:
- Use Server Components (the default in Next.js App Router)
- Fetch data in page.tsx or layout.tsx, not in client components
- Cache responses with revalidation intervals
Check Your Bundle Size
Run npx next build and look at the output. If any route is over 200KB, dig into what is making it big.
Common culprits:
- Date libraries (moment.js is 70KB, use date-fns or dayjs instead)
- Icon libraries (importing the whole set instead of individual icons)
- UI frameworks (some are heavier than you think)
Caching
Set proper cache headers for static assets. Vercel does this by default for Next.js apps, but check your API routes. Database queries that do not change often should be cached with ISR (Incremental Static Regeneration) or manual cache-control headers.
Measure Before and After
Run Lighthouse in Chrome DevTools before making changes. Note your scores. Make one change at a time and measure again. This way you know what actually helped.
Target scores: Performance 90+, Accessibility 90+, Best Practices 90+.
Related Articles
What Code Do AI Builders Actually Generate?
Under the hood, most AI builders use React, Next.js, and Tailwind. Here is why and what that means for you.
How the AI Builder Works Inside
From your prompt to working code. The pipeline, the choices we made, and why.
Row Level Security in Supabase
How to make sure users can only see their own data. Step by step RLS policies explained.
Ready to try it?
Build your first app in a few minutes.
Start Building