nextjs16-ai-sdk-v6
Production-ready skill for building Next.js 16 applications with Vercel AI SDK v6. Use when developing web applications with the latest Next.js 16 features (Turbopack, Cache Components, PPR, React 19.2) combined with AI SDK v6 agent abstractions, tool approval, and streaming patterns. Triggers include requests to create Next.js 16 projects, implement AI chat/agents, use Cache Components, setup PPR, create agentic workflows, or any modern Next.js + AI development.
Next.js 16 + AI SDK v6 Development Skill
Modern web application development with Next.js 16 (stable October 2025) and AI SDK v6 (beta, stable end of 2025).
Quick Start
New Project Setup
Essential Configuration
Version Requirements
| Package | Version | Notes |
|---|---|---|
| Node.js | 20.9.0+ | Node 18 no longer supported |
| Next.js | 16.x | npm install next@beta |
| React | 19.2+ | Included with Next.js 16 |
| AI SDK | 6.x beta | npm install ai@beta |
| TypeScript | 5.1.0+ | Recommended |
Core Concepts
Next.js 16 Key Features
- Turbopack Default - 2-5x faster builds, 10x faster hot reload
- Cache Components - Explicit caching with
'use cache'directive - PPR (Partial Prerendering) - Static shells + dynamic streaming
- React 19.2 - View Transitions,
useEffectEvent(),<Activity/> - Async Params - Route params are now async (breaking change)
AI SDK v6 Key Features
- Agent Abstraction -
ToolLoopAgenthandles tool loops automatically - Tool Approval - Built-in human-in-the-loop with
needsApproval: true - Type Safety -
InferAgentUIMessagefor type-safe UI messages - Minimal Breaking Changes - Most v5 code works in v6
Architecture Patterns
Pattern 1: Basic Chat (No Agents)
Pattern 2: Agent with Tools (v6)
Pattern 3: Tool Approval (Human-in-the-Loop)
Pattern 4: Cache Components with AI
Breaking Changes Checklist
Next.js 16 Breaking Changes
-
Async Params: Update
paramsandsearchParamsto useawaithljs typescript -
Image Changes: Default
qualitynow 75,localPatternsrequired for query strings -
Node.js 20+: Minimum version is now 20.9.0
AI SDK v6 Breaking Changes
- Use
createAgentUIStreamResponsefor agent routes (instead oftoDataStreamResponse) - Use
convertToModelMessagesto transform UI messages for agents - Add
needsApproval: trueto tools requiring confirmation
Reference Documentation
For detailed API reference and patterns, see:
references/nextjs16-api.md- Complete Next.js 16 API referencereferences/ai-sdk-v6-api.md- Complete AI SDK v6 API referencereferences/patterns.md- Advanced patterns and workflowsreferences/migration.md- Detailed migration guides
Common Issues & Solutions
Issue: "params is not a Promise"
Solution: Wrap params access in async function with await
Issue: Tool loops not working
Solution: Use ToolLoopAgent instead of manual maxSteps in streamText
Issue: Cache not invalidating
Solution: Add proper cacheTag() and call revalidateTag() or updateTag()
Issue: Approval UI not showing
Solution: Check toolInvocations array and state === 'approval-requested'
Best Practices
- Use ToolLoopAgent for any multi-step tool workflows
- Wrap dynamic content in Suspense for PPR benefits
- Use
'use cache'explicitly - nothing is cached by default in Next.js 16 - Add
needsApprovalto destructive operations (delete, update, send) - Use TypeScript with
InferAgentUIMessagefor type-safe agent UIs - Pin beta versions to avoid breaking changes in patches