Most serverless functions run in a single region. Supabase Edge Functions run on Deno Deploy's global network — your code executes in 30+ regions, closest to your users. And the free tier gives you 500,000 invocations/month.
Here's why this matters and how to use it.
What Are Supabase Edge Functions?
Edge Functions are server-side TypeScript functions that run on Deno — globally distributed, with zero cold starts on warm instances. They integrate natively with Supabase Auth, Database, and Storage.
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
serve(async (req) => {
const { name } = await req.json()
return new Response(
JSON.stringify({ message: \`Hello \${name}!\` }),
{ headers: { "Content-Type": "application/json" } }
)
})
Quick Setup
npm install -g supabase
supabase init
supabase functions new my-function
supabase functions serve
supabase functions deploy my-function
Real-World: Webhook Handler with Database Access
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
import { createClient } from "https://esm.sh/@supabase/supabase-js@2"
serve(async (req) => {
const supabase = createClient(
Deno.env.get("SUPABASE_URL")!,
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!
)
const payload = await req.json()
const { error } = await supabase
.from("webhooks")
.insert({ event: payload.event, data: payload.data })
if (error) return new Response(JSON.stringify({ error }), { status: 500 })
return new Response(JSON.stringify({ received: true }), { status: 200 })
})
Free Tier Limits
| Feature | Free | Pro ($25/mo) |
|---|---|---|
| Invocations | 500K/month | 2M/month |
| Script size | 10MB | 50MB |
| Execution time | 150s | 400s |
Edge Functions vs. AWS Lambda vs. Cloudflare Workers
| Feature | Supabase Edge | AWS Lambda | CF Workers |
|---|---|---|---|
| Runtime | Deno | Node/Python/etc | V8 isolates |
| Cold start | ~50ms | 100-500ms | ~0ms |
| Global edge | Yes | Per-region | Yes |
| Native DB | Supabase | DynamoDB | D1/KV |
| Free tier | 500K/mo | 1M/mo | 100K/day |
Supabase Edge Functions win when you already use Supabase — the native integration with Auth, Database, and Storage means zero config for common patterns.
Pro Tips
-
Use secrets for API keys:
supabase secrets set MY_KEY=value\ -
Share code between functions: put shared modules in
supabase/functions/_shared/\ - CORS handling: add CORS headers in a shared utility
Need to automate data collection or build custom scrapers? Check out my Apify actors for ready-made tools, or email spinov001@gmail.com for custom solutions.
Top comments (0)