The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
---
id: routing
title: Routing
description: Build complete REST APIs with Edge Functions using all standard HTTP methods.
subtitle: Handle different request types in a single function to create efficient APIs.
---
## Overview
Edge Functions support **`GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `OPTIONS`**. This means you can build complete REST APIs in a single function:
```tsx
Deno.serve(async (req) => {
const { method, url } = req
const { pathname } = new URL(url)
// Route based on method and path
if (method === 'GET' && pathname === '/users') {
return getAllUsers()
} else if (method === 'POST' && pathname === '/users') {
return createUser(req)
}
return new Response('Not found', { status: 404 })
})
```
Edge Functions allow you to build APIs without needing separate functions for each endpoint. This reduces cold starts and simplifies deployment while keeping your code organized.
<Admonition type="note">
HTML content is not supported. `GET` requests that return `text/html` will be rewritten to `text/plain`. Edge Functions are designed for APIs and data processing, not serving web pages. Use Supabase for your backend API and your favorite frontend framework for HTML.
</Admonition>
---
## Example
Here's a full example of a RESTful API built with Edge Functions.
<$CodeSample
path="edge-functions/supabase/functions/restful-tasks/index.ts"
lines={[[1, -1]]}
meta="index.ts"
/>