Next.js Integration
@vestig/next provides first-class support for Next.js 15+ with the App Router.
Installation
bash
Features
- Automatic correlation — Request IDs propagate through the entire request lifecycle
- Server Components —
getLogger()with React cache integration - Route Handlers —
withVestig()wrapper with automatic timing - Server Actions —
vestigAction()for form handling and mutations - Middleware — Request/response logging with correlation IDs
- Client Components — React hooks with real-time log streaming
Quick Setup
1. Create Middleware
typescript
2. Add Provider (for Client Components)
typescript
3. Use in Server Components
typescript
4. Use in Route Handlers
typescript
5. Use in Server Actions
typescript
6. Use in Client Components
typescript
How Correlation Works
text
Next Steps
- Middleware — Request/response logging configuration
- Server Components — Using
getLogger()in RSC - Route Handlers — API route logging with
withVestig() - Server Actions — Form handling with
vestigAction() - Client Components — React hooks and providers