Introduction
Supabase Edge Functions are server-side TypeScript functions that run on Deno, distributed globally at the edge for low latency. They’re perfect for custom business logic, third-party API integrations, and any server-side processing you need.Edge Functions run on Deno Deploy, providing a fast, secure runtime with global distribution.
Key Features
TypeScript Native
Write functions in TypeScript with full type safety and modern JavaScript features
Global Distribution
Functions run on edge servers worldwide for minimal latency
Secure by Default
Automatic JWT verification and built-in authentication context
Seamless Integration
Direct access to your Supabase database, auth, and storage
What You Can Build
API Integrations
Connect to third-party services:- Payment processing: Stripe, PayPal webhooks
- Email sending: Resend, SendGrid, Mailgun
- AI services: OpenAI, Anthropic, HuggingFace
- Social platforms: Twitter, Discord, Slack bots
Custom Business Logic
- Complex calculations and data transformations
- Batch processing and scheduled jobs
- Custom authentication flows
- PDF generation and image processing
Database Operations
- Complex queries with RLS enforcement
- Data validation and sanitization
- Aggregations and analytics
- Database triggers and webhooks
Quick Start
Create Your First Function
Deploy the Function
Invoke the Function
From your client application:Real-World Examples
Stripe Webhook Handler
Process Stripe webhooks securely:OpenAI Integration
Stream completions from OpenAI:RESTful API with Database Access
Create a full REST API with RLS:Core Concepts
Deno Runtime
Edge Functions run on Deno, which provides:- TypeScript native: No build step required
- Secure by default: Explicit permissions for file, network, and environment access
- Web standard APIs: Fetch, Request, Response, URL, etc.
- NPM and Deno modules: Import from both ecosystems
Environment Variables
Access secrets and configuration:Authentication Context
Access the authenticated user:Best Practices
Error Handling
Always handle errors gracefully:CORS Configuration
Handle browser requests properly:Performance Optimization
- Minimize cold starts: Keep functions small and focused
- Cache expensive operations: Use in-memory caching for repeated requests
- Stream large responses: Use streaming for large data
- Parallel processing: Use Promise.all for independent operations
Limits and Pricing
Check your project’s Edge Functions limits in the Supabase Dashboard under Settings > Usage.
Common Limits
- Execution time: 150 seconds max (Pro plan), 10 seconds (Free plan)
- Memory: 512 MB per function
- Request size: 10 MB max
- Response size: 10 MB max
Billing
- Free tier: 500K function invocations/month
- Pro plan: 2M invocations/month included
- Additional: $2 per 1M invocations
Next Steps
Quickstart
Build and deploy your first Edge Function
Deploy Functions
Learn deployment strategies and CI/CD
Environment Variables
Manage secrets and configuration
Debugging
Debug and monitor your functions
