0
0
Supabasecloud~10 mins

Creating Edge Functions with Deno in Supabase - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Creating Edge Functions with Deno
Write Deno Function Code
Save as edge function file
Deploy to Supabase Edge
Supabase runs function on request
Function executes and returns response
Client receives response
This flow shows how you write a Deno function, deploy it as an edge function on Supabase, and how it runs when a client calls it.
Execution Sample
Supabase
export async function handler(req) {
  return new Response('Hello from Edge!')
}
A simple Deno edge function that returns a greeting response when called.
Process Table
StepActionInputOutputNotes
1Function receives HTTP requestRequest objectN/AEdge function triggered by client request
2Function executes handlerRequest objectResponse objectRuns the exported handler function
3Return responseN/AResponse object with message 'Hello from Edge!'Response sent back to client
4Client receives responseResponse objectDisplays messageClient sees 'Hello from Edge!'
5EndN/AN/AFunction execution complete
💡 Function completes after sending response to client
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
requndefinedRequest objectRequest objectRequest objectRequest object
responseundefinedundefinedResponse objectResponse objectResponse object
Key Moments - 3 Insights
Why does the function return a Response object instead of just a string?
The function must return a Response object because Supabase Edge expects HTTP responses with status and headers, not just plain strings. See execution_table step 3.
What triggers the edge function to run?
The edge function runs when it receives an HTTP request from a client, as shown in execution_table step 1.
Can the function access external APIs or databases?
Yes, inside the handler you can write code to fetch data or query databases before returning a response.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the output at step 3?
A'Hello from Edge!' wrapped in a Response object
BPlain string 'Hello from Edge!'
CRequest object
DUndefined
💡 Hint
Check the Output column in execution_table row for step 3
At which step does the client receive the response?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Look at the Action and Notes columns in execution_table for when client gets the response
If the function returned a plain string instead of a Response object, what would happen?
ASupabase would automatically convert it to a Response
BThe function would fail or return an error
CThe client would receive the string without HTTP headers
DThe function would run twice
💡 Hint
Refer to key_moments about why Response object is required
Concept Snapshot
Creating Edge Functions with Deno on Supabase:
- Write an async handler function that takes a request
- Return a Response object with your output
- Deploy the function to Supabase Edge
- Supabase runs it on HTTP requests
- Client receives the HTTP response
- Use Response for proper HTTP behavior
Full Transcript
This visual execution shows how to create and run edge functions using Deno on Supabase. First, you write a handler function that receives an HTTP request and returns a Response object. When deployed, Supabase runs this function whenever a client sends a request. The function executes, returns a response with a message, and the client receives it. Variables like the request and response objects change state during execution. Key points include the need to return a Response object and that the function triggers on HTTP requests. The quiz tests understanding of these steps and outputs.