Middleware
Run code before a request is processed. Modify headers, rewrite paths, or implement authentication logic at the edge with sub-millisecond latency. Optimize delivery without touching your origin.
Technical Specifications:
Execution Time
Sub-1ms
Runtime
Edge Light (V8)
Latency Added
< 2ms
Capabilities
Headers, Rewrites, Cookies
Scaling
Instant & Automatic
Works seamlessly with:
Example 3
Example 2
alt_route
Product Capabilities
Experience
Logic at the Edge
Intercept requests before they hit your cache or origin. Perform authentication, A/B testing, or geo-routing instantly.
- Import the 'next' helper from the edge SDK.
- Check the request properties, such as the user's country code.
- Rewrite the URL path to a localized version based on the geography.
