Every product we build starts with the same question: where will the data live? The choice affects speed, cost, how fast your team can ship and how painful growth will be. Here is how we choose between the five managed databases we use most, with the pricing and setup steps for each.
1. First decision: relational or document?
Most business software is relational: users belong to organisations, orders have line items, invoices link to customers. PostgreSQL handles this beautifully, enforces data integrity and supports powerful queries. That is why four of the five options in this guide are Postgres-based or Postgres-compatible.
Document databases such as MongoDB and Firestore store flexible JSON-like documents. They shine for content with an unpredictable shape, rapid prototyping and real-time mobile apps, but complex reporting and relationships take more work.
- Choose Postgres for SaaS, e-commerce, dashboards, finance and anything with relationships.
- Choose a document database for flexible content, event data or mobile-first real-time apps.
- If you're unsure, start with Postgres. It also stores JSON well when you need flexibility.
“The best database is the one your team understands, your budget can carry, and your product can grow into without a rewrite.”— Strategic Takeaway
2. Supabase: a complete backend on top of Postgres
Supabase gives you a full Postgres database plus authentication, file storage, real-time subscriptions, edge functions and auto-generated APIs. For startups and MVPs it removes weeks of backend work, and because it is real Postgres, you are never locked into a proprietary data model.
Pricing (checked November 2026): the Free plan includes a 500 MB database and 50,000 monthly active users, but projects pause after a week of inactivity. Pro starts at $25/month per organisation, Team is $599/month, and Enterprise is custom. Usage above the included quotas is billed separately.
Best for: MVPs, SaaS products, apps that need auth and storage out of the box, and teams who want to move fast without a dedicated backend engineer.
npm install @supabase/supabase-jsNEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-public-anon-or-publishable-keyimport { createClient } from "@supabase/supabase-js";
// One shared client for the browser. Row Level Security (RLS)
// policies in Supabase decide what each user is allowed to read/write.
export const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);
// Example: fetch the 10 latest published projects
export async function getProjects() {
const { data, error } = await supabase
.from("projects")
.select("id, title, created_at")
.eq("published", true)
.order("created_at", { ascending: false })
.limit(10);
if (error) throw error;
return data;
}3. Neon: serverless Postgres that scales to zero
Neon is pure, serverless Postgres. Its stand-out features are autoscaling, scale-to-zero (you pay nothing for compute while idle) and database branching, which lets you create an instant copy of your database for every pull request or test run.
Pricing (checked November 2026): there is a permanent Free plan (no credit card), and the paid Launch and Scale plans are fully usage-based with no monthly minimum. Compute on Launch is billed at roughly $0.106 per compute-unit hour, and storage on paid plans is unlimited and grows with use.
Best for: Next.js apps on Vercel, projects with spiky or low traffic, preview environments, and teams that want Postgres without paying for idle servers.
npm install @neondatabase/serverlessimport { neon } from "@neondatabase/serverless";
// Works over HTTP, which suits serverless and edge functions.
const sql = neon(process.env.DATABASE_URL!);
export async function getUserByEmail(email: string) {
// Always use parameters ($1) instead of string concatenation
const rows = await sql.query(
"SELECT id, name, email FROM users WHERE email = $1 LIMIT 1",
[email]
);
return rows[0] ?? null;
}4. PlanetScale: production-grade Postgres and MySQL
PlanetScale is built for teams running serious production traffic. It offers managed Postgres as well as Vitess-powered MySQL, with dedicated clusters, high availability options and Metal instances on fast local NVMe storage. Branch-based schema changes make migrations safer on large databases.
Pricing (checked November 2026): there is no free tier. Postgres starts at about $5/month for a single-node cluster, Metal starts at about $50/month, and high-availability or enterprise setups are priced by cluster size.
Best for: growing SaaS products, high-traffic apps and teams that care about predictable performance and zero-downtime schema changes.
npm install postgresimport postgres from "postgres";
// PlanetScale Postgres is standard Postgres, so any driver or ORM works.
export const sql = postgres(process.env.DATABASE_URL!, {
ssl: "require",
max: 10, // connection pool size
});
export async function getOrders(customerId: string) {
return sql`
SELECT id, total, status
FROM orders
WHERE customer_id = ${customerId}
ORDER BY created_at DESC
`;
}5. MongoDB Atlas: flexible documents at any scale
MongoDB Atlas is the managed cloud version of MongoDB. Data is stored as flexible documents, which makes it quick to evolve your schema. Atlas also includes full-text search and vector search, useful for AI features.
Pricing (checked November 2026): a free M0 cluster is available for learning. The Flex tier costs between about $8 and $30 per month with a hard cap, which keeps bills predictable. Dedicated clusters start at roughly $57/month for an M10, before backups and data transfer.
Best for: content-heavy apps, product catalogues with varied attributes, event logging and teams already comfortable with MongoDB.
npm install mongodbimport { MongoClient } from "mongodb";
const uri = process.env.MONGODB_URI!;
// Re-use one client across hot reloads in development
const globalForMongo = globalThis as unknown as { mongo?: Promise<MongoClient> };
const clientPromise = globalForMongo.mongo ?? new MongoClient(uri).connect();
if (process.env.NODE_ENV !== "production") globalForMongo.mongo = clientPromise;
export async function getProducts(category: string) {
const client = await clientPromise;
return client
.db("shop")
.collection("products")
.find({ category, inStock: true })
.limit(20)
.toArray();
}6. Firebase (Cloud Firestore): real-time apps, especially mobile
Firebase is Google's app platform. Its Firestore database syncs data to clients in real time and works offline, which makes it a favourite for mobile apps built with Flutter or React Native. Auth, hosting, push notifications and analytics come in the same ecosystem.
Pricing (checked November 2026): the Spark plan is free, with daily Firestore limits (about 1 GiB stored, 50,000 reads and 20,000 writes per day). The Blaze plan is pay-as-you-go: it keeps the free quotas and bills per read, write and GB above them. Set budget alerts, because heavy read patterns can grow costs quickly.
Best for: mobile apps, chat and collaboration features, and MVPs that need real-time sync with minimal backend code.
npm install firebaseimport { initializeApp, getApps } from "firebase/app";
import { getFirestore, collection, query, where, getDocs } from "firebase/firestore";
const app = getApps()[0] ?? initializeApp({
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
});
export const db = getFirestore(app);
export async function getOpenTasks(teamId: string) {
const q = query(collection(db, "tasks"), where("teamId", "==", teamId), where("done", "==", false));
const snapshot = await getDocs(q);
return snapshot.docs.map((doc) => ({ id: doc.id, ...doc.data() }));
}7. How we integrate a database into a client project
Whatever the provider, we follow the same pattern so the project stays clean and portable.
- Keep secrets in environment variables, never in the code or the Git repository.
- Put all database calls in a small data layer (lib/db.ts or a repository folder), so pages and components never talk to the database directly.
- Use an ORM such as Drizzle or Prisma for Postgres projects to get type-safe queries and versioned migrations.
- Use separate databases (or Neon branches) for development, staging and production.
- Enable automated backups and test a restore before launch, not after an incident.
- Add indexes for the queries your app runs most, and monitor slow queries from day one.
npm install drizzle-orm
npm install -D drizzle-kit
# generate and apply migrations from your schema file
npx drizzle-kit generate
npx drizzle-kit migrateDatabase comparison at a glance
| Database | Type | Free tier | Paid from | Best for |
|---|---|---|---|---|
| Supabase | Postgres + backend | Yes (500 MB, pauses when idle) | $25/mo (Pro) | MVPs and SaaS needing auth + storage |
| Neon | Serverless Postgres | Yes (permanent) | Usage-based, no minimum | Serverless apps, preview branches |
| PlanetScale | Postgres / MySQL | No | ~$5/mo (single node) | High-traffic production |
| MongoDB Atlas | Document | Yes (M0) | ~$8–30/mo Flex | Flexible document data |
| Firebase Firestore | Document, real-time | Yes (Spark) | Pay-as-you-go (Blaze) | Mobile and real-time apps |
Prices checked November 2026 and simplified. Usage, storage and bandwidth are billed on top. Always confirm on the official pricing page.
Official resources
Principles for deliberate execution
- 1Choose Postgres by default; reach for a document database only when your data truly has no fixed shape.
- 2Supabase is the fastest path to a full backend; Neon is the leanest Postgres; PlanetScale is built for heavy production traffic.
- 3Free tiers are perfect for prototypes, but plan the upgrade path before you launch.
- 4Keep database access behind a small data layer so switching providers later is a contained job.