Supabase Blog

Supabase Edge Runtime: Self-hosted Deno Functions

thumbnail

Supabase Edge Runtime: Self-hosted Deno Functions

Supabase Edge Runtime is an open-source web server written in Rust that uses a custom Deno runtime for self-hosting Deno Edge Functions. It provides a better local development experience and serves all functions, allowing developers to simulate their functions' resource usage and handle the behavior if they run into the limits. With Supabase CLI, developers can serve all local Edge Functions by running supabase edge.

The main benefit of Edge Runtime is the ability to self-host Deno Functions. This allows developers to deploy their functions on their own infrastructure and avoid any vendor lock-in. The demo showcases how to self-host Edge Functions on Fly.io, but other providers like Digital Ocean or AWS can also be used.

The Deno team has a 2-part blog post on how to create a custom runtime in which the Rust runtime forwards incoming HTTP requests to the Main Worker. The main difference is that the Main Worker has access to a global object called Deno, which has a restricted API and doesn't get access to the host machine's environment variables. Developers can also control the memory and duration a User Worker can run.

Upcoming features for Edge Runtime include Scheduled Functions that utilize the Main Worker to run periodic tasks.