How Supabase's Postgres, Auth, Storage, Realtime and Edge Functions map to RDS, Cognito, S3 and Lambda in your own AWS account, what each side costs you, and how to move the backend without rewriting your auth.

Supabase is Postgres with the rest of a backend around it: auth, file storage, realtime subscriptions, Edge Functions and an API generated from your schema, all behind one dashboard and one client library. For a product in its first year it removes a lot of decisions. It starts to hurt when business logic piles up in RLS policies and database functions that are hard to test, when a security review asks for customer data in the company's own AWS account, or when the backend needs workers and services that do not fit in an Edge Function.
AWS can host every one of those pieces in your own account, as separate services you assemble. This guide compares the two component by component, covers cost and lock-in, and shows a middle path that moves the backend and its Postgres into your AWS account while users keep signing in through Supabase Auth.
A Supabase project is a dedicated Postgres database with extensions such as pgvector, a connection pooler, and PostgREST generating a REST API from your schema. Clients often query the database directly through that API, and Row Level Security policies decide which rows each user sees. That works well for CRUD, and logic that grows beyond it ends up in SQL functions, triggers and Edge Functions written in TypeScript on Deno.
Amazon RDS for PostgreSQL is a managed Postgres in your VPC, with the same extension support for most common cases, automated backups and point-in-time recovery. It has no generated API, so the business logic lives in a backend service you write, test and deploy, which is more code and also code you can unit test, review and run locally.
Supabase Auth covers email, magic links, OAuth providers and MFA, and issues JWTs that the rest of the platform trusts. Storage is an S3-compatible object store with access rules written as RLS policies, and Realtime broadcasts database changes and presence to subscribed clients.
On AWS, Amazon Cognito user pools are the built-in identity option, S3 stores files with IAM and presigned URLs for access, and realtime goes through AppSync subscriptions or API Gateway WebSocket APIs. Each piece is capable, and connecting them is your job.
Supabase runs scheduled work with the pg_cron extension and queues with Supabase Queues, built on pgmq, both inside the database, and longer jobs run in Edge Functions with their own time limits. On AWS, SQS, SNS and EventBridge Scheduler run outside the database, so a slow job does not compete with queries for the same CPU.
Supabase charges a plan per organization and compute per project, plus usage for database size, storage, egress and monthly active users, as listed on its pricing page. The bundle is good value for a small app. Lock-in is moderate, since the database is standard Postgres you can pg_dump, while RLS policies tied to auth.uid(), Storage policies and Edge Functions need to be rewritten elsewhere.
AWS bills each service separately, by instance hour, request, GB stored and data transferred. A larger app usually costs less in raw cloud spend on RDS and S3, and the cost that decides the comparison is the engineering time to build and run what Supabase gave you in one project.
Encore is a backend framework with built-in infrastructure for TypeScript and Go, which suits the step after Supabase: the logic that outgrew RLS policies and Edge Functions becomes ordinary services, and the Postgres, buckets and queues they use are declared in that code and provisioned as RDS, S3 and SNS with SQS in your own AWS account. Encore does not replace Supabase Auth, so this example keeps it and verifies its tokens in an auth handler.
Install the Encore CLI with the command for your system, then create the app:
Run in your terminal to get started locally.
The auth handler checks the Authorization header against the Supabase project's JWKS endpoint, which Supabase publishes for projects that use asymmetric JWT signing keys:
// projects/auth.ts
import { APIError, Gateway, Header } from "encore.dev/api";
import { authHandler } from "encore.dev/auth";
import { createRemoteJWKSet, jwtVerify } from "jose";
const SUPABASE_URL = "https://your-project-ref.supabase.co";
const jwks = createRemoteJWKSet(new URL(`${SUPABASE_URL}/auth/v1/.well-known/jwks.json`));
interface AuthParams {
authorization: Header<"Authorization">;
}
interface AuthData {
userID: string;
email: string | null;
}
export const auth = authHandler<AuthParams, AuthData>(async ({ authorization }) => {
const token = authorization?.replace(/^Bearer /, "");
if (!token) throw APIError.unauthenticated("missing token");
try {
const { payload } = await jwtVerify(token, jwks, {
issuer: `${SUPABASE_URL}/auth/v1`,
audience: "authenticated",
});
return { userID: payload.sub!, email: (payload.email as string) ?? null };
} catch {
throw APIError.unauthenticated("invalid token");
}
});
export const gateway = new Gateway({ authHandler: auth });
The migration creates a projects table with id, owner_id TEXT, name and created_at. Each query filters on the user ID from the token, the check an RLS policy on auth.uid() used to do, now in code you can test:
// projects/projects.ts
import { api, APIError } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { getAuthData } from "~encore/auth";
// RDS in your AWS account, started locally by `encore run`.
const db = new SQLDatabase("projects", { migrations: "./migrations" });
interface Project {
id: number;
name: string;
}
export const create = api(
{ expose: true, auth: true, method: "POST", path: "/projects" },
async ({ name }: { name: string }): Promise<Project> => {
if (!name.trim()) throw APIError.invalidArgument("name is required");
const { userID } = getAuthData()!;
const row = await db.queryRow<Project>`
INSERT INTO projects (owner_id, name) VALUES (${userID}, ${name.trim()})
RETURNING id, name`;
return row!;
},
);
export const list = api(
{ expose: true, auth: true, method: "GET", path: "/projects" },
async (): Promise<{ projects: Project[] }> => {
const { userID } = getAuthData()!;
const projects: Project[] = [];
for await (const row of db.query<Project>`
SELECT id, name FROM projects WHERE owner_id = ${userID} ORDER BY id`) {
projects.push(row);
}
return { projects };
},
);
encore run starts Postgres locally and applies the migration, and the frontend keeps calling supabase.auth.signInWithPassword and sends the session's access token to this API. Moving existing data is a pg_dump of the tables you own (not the auth schema) restored into the new database. On push, Encore provisions the RDS database and the services on ECS in a VPC in your account, and Encore provisions an IAM role for the service. A coding agent asked to add sharing between users writes the new table and the permission check in the same change and runs it against the local database, where a policy bug in RLS would only show up once the request hit Supabase.
The database docs cover migrations, queries and transactions in more detail.
Best fit: teams whose Supabase app has grown real backend logic and who want that logic and its Postgres in their own AWS account, with Supabase Auth kept as the sign-in layer.
Supabase is the faster choice when most of the app is CRUD that RLS expresses well, auth, storage and realtime are all needed, and nobody requires the data to sit in a particular cloud account. The client libraries and dashboard save a small team weeks.
Best fit: early products and apps whose logic fits in RLS policies and a few Edge Functions.
Rebuilding Supabase on AWS by hand means RDS, Cognito, S3 with presigned URLs, Lambda or ECS for logic, SQS and EventBridge Scheduler for background work, and AppSync or API Gateway WebSockets for realtime, joined with IAM roles and a VPC in Terraform or CDK. It is the most flexible path, and the most work.
Best fit: teams with platform engineers who want each AWS service configured to their own standards.
Stay on Supabase while RLS and Edge Functions carry the logic and data residency is not a requirement. Build on AWS by hand when a platform team is ready to assemble and run each service. Pick Encore when the backend has outgrown the database and you want its services and Postgres in your own AWS account, with Supabase Auth kept or replaced later.
No. Supabase is faster to start with, because Postgres, auth, file storage, realtime and an auto-generated API come in one project. AWS is the better home when the database must sit in your own account and network, when the backend has grown beyond what database functions and Edge Functions handle comfortably, or when the rest of the company already runs on AWS.
Yes. Supabase's hosted platform runs projects on AWS infrastructure that Supabase manages, in Supabase's accounts. Your project does not live in your AWS account, so your VPC, IAM roles and CloudTrail do not cover it. Teams that need it in their own account can self-host the open source Supabase stack.
There is no single service. Supabase's Postgres maps to RDS or Aurora, Auth to Amazon Cognito or a third-party identity provider, Storage to S3, Edge Functions to Lambda or containers on ECS, and Realtime to AppSync or API Gateway WebSockets. On AWS each one is configured and connected separately.
Yes. Supabase Auth issues JWTs that your backend can verify against the project's JWKS endpoint, so the backend and its Postgres can run in your AWS account while users keep signing in through Supabase. In Encore, an auth handler verifies the token and every endpoint marked auth: true receives the user ID.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.