The
@sentry/vercel-edge package is a low-level building block. For Next.js applications on Vercel, use @sentry/nextjs which includes Edge Runtime support automatically.Installation
When to Use
Use@sentry/vercel-edge for:
- Standalone Edge Functions on Vercel
- Edge Middleware (if not using Next.js)
- Custom Edge applications
@sentry/nextjs instead, which includes full Edge Runtime support.
Basic Setup
Edge Function
Edge Middleware
Error Handling
Manual Error Capture
Validation Errors
Performance Monitoring
Custom Spans
External API Calls
Database Queries
Context and User Information
Request Context
User Identification
Edge Runtime Limitations
Environment Variables
Configure via Vercel dashboard or.env:
Vercel Integration
Preview Deployments
Edge Config
Use Vercel Edge Config for feature flags:Best Practices
Use Next.js SDK
For Next.js apps, use @sentry/nextjs instead of this package.
Minimize Bundle
Keep edge function bundles small for fast cold starts.
Set Context
Add geo and request data for better debugging.
Sample Wisely
Use lower sample rates in production to control volume.
Troubleshooting
Bundle Size Errors
Bundle Size Errors
Edge functions have strict size limits:
- Minimize dependencies
- Use dynamic imports where possible
- Check bundle analyzer output
Timeout Issues
Timeout Issues
Edge functions have execution time limits:
- Optimize async operations
- Use appropriate timeouts for external calls
- Consider moving heavy operations to serverless functions
Next Steps
Next.js
Use Next.js SDK for full framework support
Edge Middleware
Advanced middleware patterns
Edge Config
Use Vercel Edge Config
Vercel
Vercel deployment best practices