Can I connect from serverless and edge functions?

Yes, over HTTP. Serverless and edge code talks to SupaHost through the Data API with supabase-js, which needs no connection pool. Direct Postgres connections aren't available there.

Yes, through HTTP. Vercel Functions, Netlify Functions, AWS Lambda, Cloudflare Workers and SupaHost's own Edge Functions all reach your project with supabase-js (or plain fetch) against the Data API. They can't open a direct Postgres connection to a SupaHost project: port 5432 isn't on the internet, and SupaHost has no connection pooler.

Why HTTP fits serverless

Serverless platforms start many short-lived copies of your code. If each opened its own Postgres connection, a traffic spike could exhaust the server's connection slots. That's why other hosts put a pooler in front of Postgres.

With the Data API, your function makes an HTTPS request and PostgREST runs the query from its own small, steady pool (5 connections per project on SupaHost). Thousands of concurrent function calls don't turn into thousands of Postgres connections. There's also no TCP or TLS handshake to the database on cold start, and edge runtimes without TCP sockets work fine.

Example: a Cloudflare Worker

import { createClient } from '@supabase/supabase-js'

export default {
  async fetch(request: Request, env: { SUPABASE_URL: string; SUPABASE_SERVICE_ROLE_KEY: string }) {
    const supabase = createClient(env.SUPABASE_URL, env.SUPABASE_SERVICE_ROLE_KEY, {
      auth: { persistSession: false },
    })
    const { data, error } = await supabase
      .from('bookings')
      .select('id, starts_at')
      .gte('starts_at', new Date().toISOString())
      .limit(20)
    if (error) return new Response(error.message, { status: 500 })
    return Response.json(data)
  },
}

Use the service_role key only in server-side code like this. When the function acts for a signed-in user, create the client with the anon key and pass the user's access token in the Authorization header so RLS applies to them:

const supabase = createClient(env.SUPABASE_URL, env.SUPABASE_ANON_KEY, {
  global: { headers: { Authorization: request.headers.get('Authorization')! } },
})

Complex queries

If a query is too involved for the query builder (multi-table updates, transactions, window functions), write it as a Postgres function and call it with supabase.rpc(). It runs in a single transaction inside the database.

FAQ

Can I use Prisma or Drizzle from a Vercel Function?

Not with a direct connection; there's no public Postgres port or pooler. Use supabase-js at runtime. Prisma and Drizzle can still generate your schema and SQL migrations (see Can I use Drizzle or Prisma without supabase-js?).

Is there a connection limit for HTTP clients?

SupaHost doesn't charge by request or connection. What limits throughput is the size of the VM, which depends on your plan's VM; measured API reads were about 300/s on Builder, 540/s on Pro and 950/s on Business.

Where should I run my functions?

Close to your instance's region for the lowest latency. SupaHost's own Edge Functions run on the instance itself.

Updated 11 November 2026 · View as Markdown · Something wrong or missing? Tell us