The main alternatives to Supabase Edge Functions for webhooks, background work and APIs, compared on time and memory limits, runtimes, databases, background jobs and where the code runs, with an example of a webhook backend in your own AWS or GCP account.

Supabase Edge Functions run TypeScript on Deno next to a Supabase project, which makes them the quickest way to ship a webhook receiver or a signup email. Each worker gets 2 seconds of CPU time, 256 MB of memory and at most 400 seconds of wall clock time on paid plans.
Retries, queues and long jobs then spread across pg_cron, database triggers and more functions, which is usually when teams look at the alternatives below.
Deno runtime, 256 MB of memory, 2 seconds of CPU time per worker, a wall clock limit of 150 seconds on Free and 400 seconds on paid plans, and 500,000 invocations on Free and 2 million on Pro before $2 per million, from the Edge Functions limits and pricing pages, checked December 1, 2026.
Encore is a backend framework with built-in infrastructure, and it takes the jobs that Edge Functions start, such as webhooks, emails and data syncs, and runs them as services with their own Postgres database, Pub/Sub topics and cron jobs declared in the code. On deploy it creates them in your own cloud account, as Fargate services with RDS, SNS and SQS on AWS or Cloud Run with Cloud SQL and Pub/Sub on GCP, so a job that needs ten minutes or five retries is a subscription setting instead of a workaround.

Run in your terminal to get started locally.
A payment webhook is the most common Edge Function, and it moves over as a raw endpoint. The payments folder needs an encore.service.ts that exports new Service("payments"). The endpoint checks the HMAC signature with a secret, stores the event under its provider ID so a resent webhook is ignored, and hands the processing to a subscriber that only moves an order from pending to paid:
// payments/webhook.ts
import { api } from "encore.dev/api";
import { secret } from "encore.dev/config";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { Topic, Subscription } from "encore.dev/pubsub";
import { createHmac, timingSafeEqual } from "node:crypto";
const db = new SQLDatabase("payments", { migrations: "./migrations" });
const webhookSecret = secret("PaymentsWebhookSecret");
interface PaymentSucceeded {
eventId: string;
orderId: number;
}
export const paymentSucceeded = new Topic<PaymentSucceeded>("payment-succeeded", {
deliveryGuarantee: "at-least-once",
});
function validSignature(body: Buffer, header: string | undefined): boolean {
if (!header) return false;
const expected = createHmac("sha256", webhookSecret()).update(body).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(header);
return a.length === b.length && timingSafeEqual(a, b);
}
export const receive = api.raw(
{ expose: true, method: "POST", path: "/webhooks/payments" },
async (req, resp) => {
const chunks: Buffer[] = [];
for await (const chunk of req) chunks.push(chunk);
const body = Buffer.concat(chunks);
const sig = req.headers["x-signature"];
if (!validSignature(body, typeof sig === "string" ? sig : undefined)) {
resp.writeHead(401).end();
return;
}
const event = JSON.parse(body.toString()) as { id: string; type: string; orderId: number };
const stored = await db.queryRow<{ id: string }>`
INSERT INTO webhook_events (id, type, payload)
VALUES (${event.id}, ${event.type}, ${body.toString()}::jsonb)
ON CONFLICT (id) DO NOTHING
RETURNING id`;
if (stored && event.type === "payment.succeeded") {
await paymentSucceeded.publish({ eventId: event.id, orderId: event.orderId });
}
resp.writeHead(200).end();
},
);
const _ = new Subscription(paymentSucceeded, "mark-order-paid", {
handler: async ({ orderId }) => {
await db.exec`
UPDATE orders SET status = 'paid', paid_at = now()
WHERE id = ${orderId} AND status = 'pending'`;
},
retryPolicy: { maxRetries: 10 },
});
-- payments/migrations/1_create_tables.up.sql
CREATE TABLE orders (
id BIGSERIAL PRIMARY KEY,
status TEXT NOT NULL DEFAULT 'pending',
paid_at TIMESTAMPTZ
);
CREATE TABLE webhook_events (
id TEXT PRIMARY KEY,
type TEXT NOT NULL,
payload JSONB NOT NULL,
received_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
Set the signing key with encore secret set --type local,dev,prod PaymentsWebhookSecret. encore run starts Postgres locally, applies the migration and runs the subscriber in process. A signed request is how you exercise that path: the endpoint stores the event by its ID and the in-process subscriber marks the order paid, and a second request with the same ID leaves the rows unchanged. The secrets docs and Pub/Sub docs cover environments and retry policies.
To deploy, follow Connect your cloud account and push, and the production secret value lives in Encore's secrets manager and the cloud provider's secret store rather than in the repository. An AI coding agent working on the handler does not see the production value in the code, though local values set for development are readable on the machine that runs encore run, and when it adds a refund event it changes the endpoint, the topic and a migration in one diff that it can run locally.
Best fit: Teams whose Edge Functions have become a backend and who want webhooks, retries and schedules running in their own AWS or GCP account with the Postgres database next to them.
Cloudflare Workers is the closest match to Edge Functions in shape, with TypeScript on V8 isolates deployed to Cloudflare's network and a fast cold start. The Workers limits are 10 ms of CPU time per request on Free and up to 5 minutes on Paid, with a 30 second default, and 128 MB of memory, while wall time for an HTTP request has no hard cap as long as the client stays connected. Queues, Cron Triggers and Workflows cover background work inside the same platform, D1 provides SQLite and Hyperdrive pools connections to an existing Postgres. The trade is that the code runs on Cloudflare and talks to a database in another cloud over the network.
Best fit: Teams that want an edge runtime with more CPU headroom than Edge Functions and are happy to keep the backend on Cloudflare.
AWS Lambda runs a function on Node.js, Python, Go and several other runtimes inside your own AWS account, for up to 30 minutes and with up to 10,240 MB of memory according to the Lambda quotas page. That removes the CPU and memory ceilings of Edge Functions and puts SQS, EventBridge and RDS one IAM policy away. The work moves into the surrounding setup instead, since API Gateway routes, IAM roles, VPC access for a private database and connection pooling through RDS Proxy all need to be defined, usually with SAM, CDK or Terraform.
Best fit: AWS teams with existing infrastructure code who need longer functions next to SQS and RDS.
Google Cloud Run runs any container, scales it with traffic and can take it to zero, with requests of up to 60 minutes and Cloud Run jobs for batch work that runs up to 7 days. An Edge Function written for Deno can move as a Deno or Node.js server without a rewrite of its logic, because the unit Cloud Run deploys is a container. The database, queues and schedules come from Cloud SQL, Pub/Sub, Cloud Tasks and Cloud Scheduler, each with its own service account permissions to set up.
Best fit: Teams on Google Cloud that want container flexibility and longer requests than any function platform offers.
Vercel Functions run alongside a Vercel project, with a default duration of 300 seconds and longer durations that can be configured, Node.js, Python and other runtimes, and waitUntil for work after the response. They fit code that already lives in a Next.js app, such as form handlers and webhooks for the frontend, and Vercel Queues and Schedules, both in beta, cover retries and recurring jobs. Postgres comes from a Marketplace partner, since Vercel does not run databases itself.
Best fit: Frontend teams on Vercel whose functions belong to the web app and finish within the duration limit.
Move to Cloudflare Workers when the functions stay small and the edge matters, to Lambda or Cloud Run when they need more time and memory and the team already writes infrastructure code, and to Vercel Functions when they belong to a Next.js app. Choose Encore when the functions have turned into a backend, so that the endpoints, the queues, the schedules and the database are declared together and run in your own AWS or GCP account.
Encore is the option when the functions have grown into a backend with queues, schedules and a database of their own, since it declares them in code and deploys them to your own AWS or GCP account. Cloudflare Workers is the closest edge runtime, AWS Lambda and Google Cloud Run suit longer jobs, and Vercel Functions fits code that belongs to a Next.js project.
An Edge Function worker has 256 MB of memory, 2 seconds of CPU time and a wall clock limit of 150 seconds on the Free plan and 400 seconds on paid plans. A request that gets no response within 150 seconds returns a 504.
Yes. Only within the worker wall clock limit. A function can keep working after it responds with EdgeRuntime.waitUntil, and schedules usually come from pg_cron in the database calling the function, so work longer than 400 seconds or with retries belongs in a queue and a separate worker.
Recreate it as a raw endpoint in Encore that verifies the signature with a secret, stores the event with its ID as a unique key and publishes it to a Pub/Sub topic. Encore runs it locally with encore run and deploys the endpoint, the database and the topic to your own AWS or GCP account.
Own your AWS or GCP cloud without giving up PaaS speed
Define databases, Pub/Sub, cron jobs, and object storage directly in TypeScript or Go. Encore provisions everything in your own cloud account with zero Terraform or lock-in.