Zum Hauptinhalt springen
Astro Astro Anleitung

Best Database for Astro (2026)

Compare the best database solutions for Astro. We review Astro DB, Turso, Supabase, and more with SSR integration and static site generation support.

Astro is primarily a static site generator, but with SSR mode and API routes, you can build full-stack apps. Astro DB (built on Turso) is the official database solution, but you can use any database that works with JavaScript. Your choice depends on whether you're building a static site with some dynamic features or a full web app.

Warum es wichtig ist

Not every Astro site needs a database—many are pure content sites. But for user-generated content, authentication, or dynamic features, you need a database. Astro's flexibility means you can choose build-time data (fetch once) or runtime data (fetch per request).

Wichtige Überlegungen

01

Static vs SSR

Static sites can fetch database data at build time only. SSR mode enables per-request database queries. Hybrid mode lets you mix both approaches per route.

02

Astro DB

Astro DB is the official solution, built on Turso (libSQL). Seamless integration, local dev support, type-safe queries. Best DX for Astro-specific projects.

03

Edge Deployment

Astro deploys to Cloudflare, Vercel Edge, and Deno Deploy. Edge targets need databases with HTTP drivers (Turso, Neon, PlanetScale).

04

Type Safety

Astro has excellent TypeScript support. Astro DB provides full type inference. Other ORMs (Prisma, Drizzle) also work well.

05

Bundled Services

For full-stack apps, consider Supabase (database + auth + storage) or PocketBase (all-in-one backend). Reduces complexity.

Unsere Empfehlungen

Turso
#1

Turso

Beste Gesamtlösung Ausgezeichnet Unterstützung Offizielles SDK

Astro DB is built on Turso, making libSQL the official choice. Use Astro DB for seamless integration or Turso directly for more control. Edge-native, globally replicated, generous free tier (9GB). Perfect for Astro.

npx astro add db
Supabase
#2

Supabase

Beste Full Stack Gut Unterstützung Offizielles SDK

Supabase provides PostgreSQL + auth + storage. Great for Astro apps needing user accounts. SSR helpers available. Generous free tier (500MB, unlimited auth users).

npm install @supabase/supabase-js
Neon
#3

Neon

Beste PostgreSQL Serverless Gut Unterstützung Offizielles SDK

Neon is serverless PostgreSQL with instant branching. Edge-compatible driver works with Astro on all platforms. Good free tier (0.5GB with branching). Great if you want PostgreSQL power.

npm install @neondatabase/serverless
Prisma
#4

Prisma

Beste ORM Gut Unterstützung Offizielles SDK

Prisma works well with Astro's SSR mode. Type-safe queries, great migrations, works with any PostgreSQL/MySQL database. Prisma Accelerate adds edge support.

npx prisma init
PlanetScale
#5

PlanetScale

Beste zum Skalieren Gut Unterstützung Offizielles SDK

PlanetScale is serverless MySQL with unlimited horizontal scaling. Database branching for safe migrations. No free tier but excellent for production workloads.

npm install @planetscale/database

Schnellvergleich

Service TypeScript Edge Kostenlose Stufe Einrichtungszeit
Turso
full 9GB, 500 DBs 5 min
Supabase
full 500MB, 2 projects 10 min
Neon
full 0.5GB, branching 5 min
Prisma
full N/A (ORM) 15 min
PlanetScale
full None (paid) 10 min

Schnellstart

Use Astro DB with Type-Safe Queries src/pages/posts/[id].astro
---
import { db, Posts, eq } from 'astro:db';

export async function getStaticPaths() {
  const posts = await db.select().from(Posts);
  return posts.map((post) => ({ params: { id: post.id } }));
}

const { id } = Astro.params;
const [post] = await db.select().from(Posts).where(eq(Posts.id, Number(id)));

if (!post) return Astro.redirect('/404');
---

<article>
  <h1>{post.title}</h1>
  <p>{post.content}</p>
</article>

Häufige Integrationsmuster

Astro DB + SSR

Astro DB for data, SSR mode for dynamic content. Type-safe queries with drizzle syntax. Simplest full-stack Astro setup.

turso

Supabase + Astro Hybrid

Supabase for database and auth, Astro hybrid mode for static pages with some dynamic routes. Best for apps with user accounts.

supabase supabase-auth

Prisma + Neon + Vercel

Type-safe ORM with Prisma, serverless PostgreSQL with Neon, deployed to Vercel. Standard production stack.

prisma neon vercel

Häufig gestellte Fragen

Does Astro need a database?
No, many Astro sites are pure static with no database. Use Content Collections for Markdown content. Only add a database for user-generated content, authentication, or dynamic data.
What is Astro DB?
Astro DB is Astro's official database solution, built on Turso (libSQL/SQLite). It provides seamless integration with Astro, local development with seeding, and type-safe queries using drizzle syntax.
Can I use Astro DB for free?
Astro DB uses Turso under the hood. Turso has a generous free tier (9GB storage, 500 databases). For development, Astro DB runs locally with no cloud dependency.
Should I use Astro DB or another database?
Use Astro DB for the best integration and DX. Use Supabase if you need auth bundled. Use PostgreSQL (Neon) if you need its specific features. Astro DB is sufficient for most use cases.

Verwandte Anleitungen

Zuletzt aktualisiert: January 11, 2026