Developing Functions locally
Setting Up Your Environment#
You can follow the Deno guide for setting up your development environment with your favorite editor/IDE.
When developing with VS Code inside of an existing application, you can utilize multi-root workspaces.
For example, see this edge-functions.code-workspace
configuration for a CRA (create react app) client with Supabase Edge Functions. You can find the complete example on GitHub.
Running Edge Functions locally#
You can run your Edge Function locally using supabase functions serve
:
The functions serve
command has hot-reloading capabilities. It will watch for any changes to your files and restart the Deno server.
Invoking Edge Functions locally#
While serving your local Edge Function, you can invoke it using curl:
or using one of the client libraries, e.g. using supabase-js:
You should see the response { "message":"Hello Functions!" }
.
If you execute the function with a different payload the response will change.
Modify the --data '{"name":"Functions"}'
line to --data '{"name":"World"}'
and try invoking the command again!
note
- Edge Functions don't serve HTML content (
GET
requests that returntext/html
are rewritten totext/plain
). - The
Authorization
header is required. You can use either theANON
key, theSERVICE_ROLE
key, or a logged-in user's JWT. - The Function is proxied through the local API (
http://localhost:54321
)