@vestig/next API Reference
Complete API documentation for the Next.js integration package.
Installation
bash
Server Exports
Import from @vestig/next:
typescript
getLogger
Get a logger for Server Components with automatic context propagation.
typescript
Usage:
typescript
Notes:
- Uses React
cache()for request deduplication - Automatically includes correlation context from middleware
- Creates child logger with the given namespace
getRequestContext
Get the current request's correlation context.
typescript
Usage:
typescript
withVestig
Wrap Route Handlers for automatic logging and context.
typescript
Usage:
typescript
vestigAction
Wrap Server Actions for automatic logging and context.
typescript
Usage:
typescript
Client Exports
Import from @vestig/next/client:
typescript
VestigProvider
Provider component for client-side logging.
typescript
Usage:
typescript
useLogger
Get a logger instance in Client Components.
typescript
Usage:
typescript
useCorrelationContext
Get the correlation context in Client Components.
typescript
Usage:
typescript
useVestigConnection
Monitor the connection to the log streaming server.
typescript
VestigErrorBoundary
Error boundary with automatic error logging.
typescript
Usage:
typescript
Middleware Exports
Import from @vestig/next/middleware:
typescript
createVestigMiddleware
Create Next.js middleware with automatic request logging.
typescript
Usage:
typescript
Types
typescript