Supabase Edge Functions: Vocabulary for Serverless Deno Development
Master the English terms for Supabase Edge Functions — Deno runtime, CORS, database triggers, secrets, and deployment — for ESL backend developers.
Supabase Edge Functions are server-side TypeScript functions that run on Deno Deploy’s global network. They are triggered by HTTP requests, database events, or scheduled jobs, and they have direct access to your Supabase project’s database, storage, and auth services. Understanding the vocabulary in this post will help you read the Supabase documentation, write clear commit messages about edge function changes, and discuss serverless architecture in English.
Core Concepts
Edge Function — a small, stateless server-side function deployed to Supabase’s global edge network; it handles a single HTTP endpoint or responds to a Supabase database event.
“We moved the payment webhook handler to an Edge Function so it runs close to the payment provider’s servers and responds in under 50 ms.”
Deno runtime — the JavaScript and TypeScript runtime that executes Supabase Edge Functions; unlike Node.js, Deno uses ES module imports with URLs and has a built-in permissions model.
“Because the Deno runtime uses URL imports, we import the Supabase client directly from esm.sh rather than running npm install.”
stateless — describes a function that does not retain any memory or state between invocations; each call to an Edge Function starts fresh, with no knowledge of previous requests.
“Edge Functions are stateless, so we store session data in the Supabase database rather than in a module-level variable.”
HTTP and CORS
CORS headers — HTTP response headers that tell the browser which origins are permitted to call your Edge Function from client-side JavaScript; missing CORS headers cause the browser to block the response.
“We added CORS headers to the function response so the React app running on localhost:3000 could call the Edge Function during development.”
preflight request — an automatic OPTIONS request the browser sends before a cross-origin fetch to check whether the server allows the actual request; Edge Functions must handle this and respond with the correct CORS headers.
“The function was failing silently in production because it was not handling the preflight request, causing the browser to cancel the actual fetch.”
invoke() — the method on the Supabase client that calls an Edge Function by name from client-side or server-side code, passing a body and optional headers.
“We call supabase.functions.invoke(‘send-email’, options) on the client so the user never needs to know the function’s URL.”
Database Triggers and Events
database trigger — a Supabase feature that calls an Edge Function automatically when a row is inserted, updated, or deleted in a specified table, enabling event-driven workflows.
“A database trigger on the orders table calls the fulfillment Edge Function every time a new row is inserted with a status of confirmed.”
webhook — an HTTP callback that Supabase can send to an Edge Function URL when a specified database event occurs; it delivers a JSON payload describing the changed row.
“We configured a webhook so the notification Edge Function receives a JSON payload whenever a support ticket is assigned to a new agent.”
pg_net — a PostgreSQL extension available in Supabase that allows database functions and triggers to make outgoing HTTP requests directly, enabling Edge Function calls from within SQL.
“We used pg_net inside a database function to call the Edge Function synchronously rather than waiting for the trigger to fire asynchronously.”
Secrets and Deployment
secrets — environment variables stored securely in your Supabase project and injected into Edge Functions at runtime; they are never exposed in source code or logs.
“We added the third-party API key as a secret using the Supabase CLI so it is available as Deno.env.get inside the function without being committed to Git.”
supabase functions deploy — the CLI command that bundles and uploads your Edge Function source code to Supabase, making the latest version live immediately.
“After testing the function locally with supabase functions serve, we ran supabase functions deploy send-invoice to push it to production.”
watcher — the local development mode feature (supabase functions serve --watch) that automatically reloads the Edge Function whenever you save a change to the source file.
“We kept the watcher running in a terminal so every time we saved the handler file the local Edge Function restarted and we could test the new logic immediately.”
Practice
Write a minimal Supabase Edge Function that reads a name field from the JSON request body and returns a greeting. Add the correct CORS headers to the response. Then use the Supabase CLI to deploy it. In English, explain to a teammate why secrets should never be hard-coded in the function source and how they are accessed inside the Deno runtime.