Supabase7 min readUpdated November 23, 2026

What Are Supabase Edge Functions?

Serverless TypeScript that runs close to the user. Good for webhooks and small tasks, wrong for long jobs.

Supabase Edge Functions are serverless TypeScript functions built on Deno and distributed globally. They are billed per invocation: 500,000 included on Free, 2 million on Pro, then $2 per million. Use them for webhooks, small API endpoints, and third-party calls. Move long-running work to a background worker.

Edge Functions are serverless TypeScript functions built on Deno. You write a .ts file that exports a handler, and Supabase deploys it to a globally distributed runtime. Requests enter an edge gateway, the gateway validates the JWT and applies routing, and the function runs on a node close to the user.

What are Supabase Edge Functions?

Edge Functions are serverless TypeScript functions built on Deno. You write a .ts file that exports a handler, and Supabase deploys it to a globally distributed runtime. Requests enter an edge gateway, the gateway validates the JWT and applies routing, and the function runs on a node close to the user.
Because they are Deno-based, they are portable. The same function runs locally with the Supabase CLI and on any Deno-compatible platform, including self-hosted infrastructure. That matters if you ever want to move off the managed platform. They are the glue layer of a Supabase project. A webhook from Stripe, a small API endpoint, a call to an external service, an Open Graph image, or a transactional email all fit. They are not a general compute platform, and treating them like one is where teams get into trouble.

When should I use Edge Functions?

Use them for authenticated or public HTTP endpoints that need low latency, webhook receivers, on-demand image or Open Graph generation, small AI inference or orchestration calls, transactional email, and chat or messaging bots. If the job is a request in and a response out, it fits.
The common pattern is a webhook. Stripe, GitHub, or another service posts to your function, the function verifies the signature and writes to the database. That keeps the secret on the server and the logic close to the data. The pattern to avoid is long-running work. A function that processes a large file, runs a batch job, or waits on a slow external API will hit the request timeout and cost you invocations while it fails. Move that work to a background task or a queue, and let the function just enqueue it.

How are Edge Functions priced?

Invocations are billed in packages of one million. The Free plan includes 500,000 invocations. Pro and Team include 2 million, then $2 per million. If your usage falls between two packages, you are billed for the next whole package. Preflight OPTIONS requests are not billed.
The cost is small for most apps. A function that handles 100,000 webhooks a month is well inside the free quota. The cost only matters at high volume, and at that point the bigger concern is usually the database load the function creates, not the invocation fee. What is not metered per invocation is the egress the function generates. Data sent to the client counts toward your unified egress quota, so a function that returns large payloads adds to the egress bill, not the invocation bill. Keep responses small.

What are the limits and cold-start behavior?

Cold starts are possible. A function that has not run recently may take longer on the first request while the runtime spins up. Design for it: keep functions short, make them idempotent, and do not assume the first call is fast.
Concurrency and timeouts are bounded. A function is meant for a request-response cycle, not for a job that runs for minutes. If you need to process something large, enqueue it and return immediately, then let a background worker do the work. Secrets are managed as project secrets and injected as environment variables. Never hardcode a key in the function. The function code is versioned and deployable, and a key in the code is a key in your repo, which is the same leak path as any other committed secret.

How do Edge Functions connect to Postgres?

Treat Postgres as a remote, pooled service. In a serverless environment, every invocation is a new process, and a direct connection per invocation will exhaust your connection limit fast. Use the connection pooler or a serverless-friendly driver.
For simple reads and writes, the Supabase client inside the function is the easiest path. It goes through the REST API and respects row level security when you pass the user's token. For heavier queries, use a pooled Postgres connection and a query builder like Kysely. The rule is the same as any serverless database access: pool, do not connect per request. We have seen a function that opened a direct connection on every call take down a project's connection limit during a traffic spike. The fix was one line, pointing it at the pooler, and the incident never recurred.

4 Tips to Get Started

1

Keep functions short and idempotent. Cold starts are real, so design for a fast first request.

2

Store secrets in project secrets, not in the function code. They are injected as environment variables.

3

Use a pooled connection or a serverless driver for Postgres. A direct connection per invocation will exhaust your pool.

4

Move anything that runs longer than a request into a background task or a queue, not an edge function.

Ready to Stop Worrying About Infra?

Knowledge is the first step. Get a free 1-hour diagnostic and see where your infrastructure leaks time, money, and focus.

Sources & References

roqy.io cites authoritative sources including engineering blogs, vendor documentation, industry surveys, and academic research to ensure accuracy.

R

Ron Cohen — Founder & DevOps Engineer

Content reviewed by the roqy.io team. Our guides are based on publicly available data and cited sources above.

Disclaimer: This content is for informational and educational purposes only. It does not constitute professional advice or a guarantee of specific results. Infrastructure needs vary by team, stack, and stage. Consult a qualified engineer for advice tailored to your situation.

Frequently Asked Questions

What are Supabase Edge Functions?

They are serverless TypeScript functions built on Deno and distributed globally at the edge. You write a .ts file that exports a handler, deploy it with the CLI, and it runs close to the user. They are good for webhooks, small endpoints, and third-party API calls.

How much do Supabase Edge Functions cost?

Invocations are billed per million. The Free plan includes 500,000 invocations. Pro and Team include 2 million, then $2 per million. Preflight OPTIONS requests are not billed.

Do Supabase Edge Functions have cold starts?

Yes. Cold starts are possible, so design functions to be short-lived and idempotent. Heavy or long-running jobs should run in a background worker instead of an edge function.

Can Edge Functions connect to Postgres?

Yes, but treat Postgres as a remote, pooled service. Use a connection pool or a serverless-friendly driver. Opening a direct connection on every invocation will exhaust your connection limit.

Get the DevOps Ecosystem Behind You

One accountable engineer. Full platform behind him. Month-to-month, no lock-in.