Skip to main content
The Sentry Vercel Edge Runtime SDK provides error monitoring and performance tracking for Edge Functions and Edge Middleware running on Vercel’s Edge Network.
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
For Next.js applications, use @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

The Edge Runtime has limitations:
  • No Node.js APIs (fs, path, etc.)
  • Smaller bundle size limits
  • Limited execution time
  • No native modules
Sentry automatically adjusts for these constraints.

Environment Variables

Configure via Vercel dashboard or .env:
Access Vercel system environment variables:

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

Edge functions have strict size limits:
  1. Minimize dependencies
  2. Use dynamic imports where possible
  3. Check bundle analyzer output
Edge functions have execution time limits:
  1. Optimize async operations
  2. Use appropriate timeouts for external calls
  3. 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