Edge Functions
Code at the Edge
Run JavaScript at the edge with three function types. Auth middleware, content filters, and standard functions - with KV stores and AI-powered code assistance.
/api/userProcess Requests & Responses
Standard edge functions run on every matching request. Build API proxies, transform requests, enrich data from external APIs, or implement rate limiting and geo-routing.
- API proxies with auth
- Request transformation
- Data enrichment
- Geo-location routing
Edge function docs
Protect Routes with Authentication
Auth middleware protects routes by validating tokens, sessions, or custom logic. Return status 201 to grant access, or 401/403 to deny. Chain multiple middleware for layered security.
- JWT validation
- Session checks
- IP whitelisting
- Chainable middleware
Auth middleware docs
Transform HTML Responses
Content filters transform HTML responses as they stream to clients. Extend TransformStream to inject scripts, replace content, add analytics, or modify HTML in real-time.
- HTML transformation
- Script injection
- Content replacement
- Analytics insertion
Content filter docs
Edge Functions Use Cases
Three function types for different use cases.
Auth Middleware
Protect routes with JWT validation, session checks, or IP whitelisting. Chain multiple middleware for MFA flows.
- JWT validation
- Session checks
- Chainable middleware
API Proxies
Build API gateways that authenticate, transform, and route requests to backend services.
- Request transformation
- Header manipulation
- KV caching
Content Filters
Transform HTML responses in real-time. Inject analytics, replace content, or add security headers.
- HTML transformation
- Script injection
- Real-time streaming
Geo Routing
Access geo data from request headers. Route users based on country, region, or custom logic.
- Country detection
- Language routing
- Regional content
KV Store
Store and retrieve key-value data from edge functions. Cache responses or store session data.
- Key-value storage
- Function state
- Caching layer
AI Code Assist
Use AI to generate function code. Context-aware prompts for each function type.
- Code generation
- Type-specific prompts
- Example templates
Start Building at the Edge
Create edge functions, auth middleware, and content filters from the dashboard.