E

Expert Nextjs Developer Companion

Streamline your workflow with this expert, next, developer, specializing. Includes structured workflows, validation checks, and reusable patterns for web tools.

AgentClipticsweb toolsv1.0.0MIT
0 views0 copies

Expert Next.js Developer Companion

Builds production-grade Next.js 16 applications using App Router, Server Components, Turbopack, and modern caching strategies.

When to Use This Agent

Choose this agent when you need to:

  • Scaffold or extend Next.js 16 apps with Server Components, layouts, and route handlers
  • Implement use cache directive, Partial Pre-Rendering, and advanced revalidation APIs
  • Configure Turbopack builds, metadata, middleware auth, and deployment pipelines

Consider alternatives when:

  • Your project uses the legacy Pages Router without migration plans
  • You need framework-agnostic React guidance without Next.js-specific patterns

Quick Start

Configuration

name: expert-nextjs-developer-companion type: agent category: web-tools

Example Invocation

claude agent:invoke expert-nextjs-developer-companion "Create a dynamic product page with ISR and async params"

Example Output

Created: app/products/[slug]/page.tsx
  - Async params (Next.js 16 breaking change)
  - generateMetadata with OG tags
  - ISR with revalidate: 3600
  - Suspense boundary for streaming
Created: app/products/[slug]/loading.tsx
Created: app/actions/update-product.ts
  - Server Action with revalidateTag

Core Concepts

Next.js 16 Feature Matrix

AspectDetails
App RouterFile-based routing with layouts, templates, route groups, and parallel routes
Cache Componentsuse cache directive for Partial Pre-Rendering and instant navigation
TurbopackDefault bundler with filesystem caching for sub-second HMR
Async ParamsBreaking change: params and searchParams are Promise types requiring await
Cache APIsupdateTag(), refresh(), and enhanced revalidateTag() for granular invalidation

Request Lifecycle

+------------------+     +------------------+     +-------------------+
|  Incoming        |---->|  Middleware       |---->|  Route            |
|  Request         |     |  (auth/redirect)  |     |  Resolution       |
+------------------+     +------------------+     +-------------------+
                                                          |
         +-------------------+     +-------------------+  |
         |  Response         |<----|  Server Component  |<-+
         |  Streaming        |     |  + Cache Layer     |
         +-------------------+     +-------------------+

Configuration

ParameterTypeDefaultDescription
next_versionstring"16"Next.js version for feature-specific patterns
typescript_strictbooleantrueStrict TypeScript with async param types
caching_strategystring"hybrid"Approach: "static", "dynamic", "hybrid", or "ppr"
turbopack_fs_cachebooleantrueEnable Turbopack filesystem cache
deployment_targetstring"vercel"Platform: "vercel", "docker", "node", or "edge"

Best Practices

  1. Always Await Params - Next.js 16 changed params and searchParams to Promise types. Every component destructuring these props must await them first. Missing await causes silent undefined values and blank pages.

  2. Default to Server Components - Start every component as a Server Component. Add 'use client' only for useState, useEffect, event handlers, or browser APIs. This minimizes bundle sizes and avoids client-server waterfalls.

  3. Leverage use cache for PPR - Mark data-fetching components with "use cache" to serve a static shell instantly while streaming dynamic content. This improves TTFB without sacrificing freshness.

  4. Colocate Route Files - Place loading.tsx, error.tsx, and components alongside page.tsx in the same directory. This makes route-state relationships explicit and prevents orphaned files.

  5. Use Granular Cache Tags - Apply entity-specific tags like product-${id} alongside collection tags. This enables surgical revalidation without flushing the entire cache.

Common Issues

  1. Stale Data After Mutations - Server Actions that forget revalidateTag or revalidatePath leave cached pages serving outdated content. Always pair mutations with explicit cache invalidation.

  2. Client Boundary Creep - Adding 'use client' to a parent forces all children to become client components. Push the boundary deep by extracting interactive elements into small leaf components.

  3. Heavy Middleware - Middleware runs on every matching request. Keep it to lightweight checks (cookie validation, redirects) and defer expensive operations to route handlers.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates