Teams often adopt Next.js expecting instant Core Web Vitals, only to discover slow Time to First Byte (TTFB), sluggish Interaction to Next Paint (INP), and bloated JavaScript bundles in production. Framework defaults help, but architecture choices decide real-world speed.
1. Audit "use client" boundaries and bundle weight
Placing "use client" on a layout or page wrapper forces the entire subtree—including formatting libraries, icons, and rich data tables—into the client bundle. Keep page shells as Server Components and push client directives down to small interactive leaves such as modals, forms, or virtualized tables.
2. Eliminate serial server waterfalls and blocking work
Sequential await calls inside Server Components multiply TTFB by every downstream round-trip. Fetch independent datasets concurrently with Promise.all, and never block HTTP responses on long-running tasks.
- Move multi-step workflows (like multi-file PR analysis in AI Code Reviewer) into asynchronous BullMQ + Redis workers returning HTTP 202 immediately.
- Cache repeatable expensive lookups using two-tier keying (such as commit-SHA caching or 60-second in-memory API caches) instead of recomputing on every request.
- Eliminate N+1 ORM queries and add targeted PostgreSQL indexes—including partial unique indexes—on hot paths.
| Symptom in Production | Common Architecture Root Cause | Production Fix & Portfolio Pattern |
|---|---|---|
| High TTFB (>800ms) | Sequential await waterfalls or dynamic headers() opt-out | Parallelize with Promise.all + add ISR / Redis cache |
| Poor INP (>200ms) | Top-level "use client" wrapper hydrating heavy UI trees | Push client leaves down; defer non-critical modals/charts |
| Request Timeout / OOM | Blocking webhook or AI inference inside API route handler | Return HTTP 202 and dispatch via BullMQ + Redis worker |
| Slow Catalog Filters | Uncached ORM joins across 10k+ product variations | Targeted PostgreSQL indexing + pre-computed filter lookups (<15ms) |
3. Align caching with content volatility
In multi-module platforms like Wood Play (Next.js 16 + Payload CMS 3 + Turso libSQL), catalog, rental, and editorial routes do not need per-request SSR regeneration. Combining 5-minute ISR with bfcache-friendly cache headers keeps navigation instantaneous while content updates remain predictable.
4. Guard LCP, CLS, and third-party scripts
- Serve AVIF/WebP assets with explicit width and height dimensions so browsers reserve layout space before pixels arrive.
- Keep loading="lazy" off above-the-fold hero images and prioritize the primary LCP resource.
- Defer or remove heavy third-party widgets that block the main thread during initial hydration.
Rule of thumb: fix server latency (TTFB) and client bundle boundaries before micro-optimizing CSS. You cannot client-optimize your way out of a slow database query.