Skip to content
Search

Supabase:Edge

lastmod 2026-03-02created 2026-03-021 edits

Edge Functions are server-side TypeScript functions, distributed globally at the edge close to your users. They can be used for listening to webhooks or integrating your Supabase project with third parties like Stripe. Edge Functions are developed using Deno, which offers several benefits to you as a developer.

Features

  • It is open source.
  • It is portable. Supabase Edge Functions run locally and on other Deno-compatible platforms (including self-hosted infrastructure).
  • It is TypeScript first and supports WASM.
  • Edge Functions are distributed globally for low latency.

How it works

  • Requests: the gateway routes traffic, handles auth header/JWT validation, and applies routing/traffic rules.
  • Auth and policies are applied. The gateway (or the function) can validate the Supabase JWT, apply rate limits, and centralize security checks before running code.
  • The Edge Runtime runs the function. The function runs on the regionally distributed Edge Runtime node closest to the user for minimal latency.
  • Integrations and data access - typically calls Supabase APIs (Auth, Postgres, Storage) or third-party APIs. For Postgres, prefer connection strategies suited to edge/serverless environments (see the connect-to-postgres guide).
  • Observability and logs — invocations emit logs and metrics that can be explored in the dashboard or in downstream monitoring (Sentry, etc.).
  • The response is returned through the gateway. The gateway relays the response back to the client and records request metadata.

Quick technical notes

  • Runtime: Supabase Edge Runtime (a TypeScript-first compatible runtime). Functions are simple .ts files that export a handler.
  • Local dev parity: use the Supabase CLI for a production-like local runtime for faster iteration (use the supabase functions serve command for a production-like local runtime for faster iteration).
  • Global deployment: deploy Edge Functions via the Supabase dashboard, CLI, or MCP.
  • Cold starts and concurrency: cold starts are possible. Design for short-lived, idempotent operations. Heavy long-running jobs should be moved to background workers.
  • Database connections: treat Postgres as a remote, pooled service — use connection pools or serverless-friendly drivers.
  • Secrets: store credentials in Supabase project secrets and access them via environment variables.

When to use Edge Functions

  • Authenticated or public HTTP endpoints that need low latency.
  • Webhook receivers (Stripe, GitHub, etc.).
  • On-demand image or Open Graph generation.
  • Small AI inference tasks or orchestrating calls to external LLM APIs (e.g., OpenAI)
  • Sending transactional emails.
  • Building messaging bots for Slack, Discord, etc.

See also

Favorite site

author Zer0 sitemap