https://astro.build/db/ Skip to content Documentation Showcase Resources * Themes * Integrations * Tutorials Blog Go to Astro's GitHub repo Join the Astro community on Discord Follow Astro on Twitter Astro Studio Show Menu Docs Showcase Resources Themes Integrations Tutorials Blog Go to Astro's GitHub repo Join the Astro community on Discord Follow Astro on Twitter Read the docs Astro Studio --------------------------------------------------------------------- Atmospheric illustration of a nebulous, breathing space scene Astro DB Early Preview The database platform for content-driven websites Astro DB is a fully-managed SQL database that is fast, lightweight, and ridiculously easy-to-use. Get started for free Read the docs No credit card required. Cancel anytime. Astro DB is a fully-managed SQL database designed exclusively for Astro. Powered by LibSQL LibSQL balanced lightweight efficiency with proven enterprise-grade performance. Scale with confidence Astro DB's automatically scales up to meet demand and scales down to $0 when inactive. Automatically configured Everything is setup for you, like a TypeScript ORM with full type-safety out of the box. Use Cases Unlimited possibilities Stop worrying about configuration, provisioning, and setup--just start building. Unlock a universe of new site features with the only drop-in database designed exclusively for Astro. * Comments * Blog * Forms * Feedback * Auth * + + // Define your Posts table const Posts = defineTable({ columns: { author: column.text(), title: column.text() content: column.text(), } }); // Retrieve all post titles by author await db.select({ title: Posts.title }) .from(Posts) .where(eq(Posts.author, "James")) * + // Configure your database schema const Comments = defineTable({ columns: { authorId: column.text(), postId: column.text(), body: column.text(), published: column.date({ default: NOW }), } }) // Insert a new comment record await db.insert(Comments).values({ authorId: "12345", postId: blogPostId, body, }) * // Define your Submissions table const FormSubmissions = defineTable({ columns: { fullName: column.text(), email: column.text(), message: column.text(), } }) // Insert a new response await db.insert(FormSubmissions).values({ fullName, email, message, }) * // Configure your database schema const Reactions = defineTable({ columns: { postId: column.number({ references: () => Post.columns.id }), emoji: column.text() } }) // Insert a new post reaction await db.insert(Reactions).values({ postId: "12345", emoji: "" }) * // Define your tables const Users = defineTable({ columns: { id: column.number({ primaryKey: true }), username: column.text() } }) const Sessions = defineTable({ columns: { id: column.number({ primaryKey: true }), userId: id: column.number({ references: () => User.columns.id }), expiresAt: column.number(), } }) // Read and validate session cookie const sessionId = context.cookies.get('session') const { session, user } = await lucia.validateSession(sessionId) // Query the user profile const profile = await db.select() .from(Users) .where(eq(Users.id, user.id)) Features Everything you need, included Atmospheric illustration of a nebulous, breathing space scene Astro logo Designed for the Astro ecosystem A deeply integrated, unified developer experience. avg min max count sum null integer real text blob select insert update delete left inner cross outer right distinct order by where limit between primary foreign unique composite alternate not null check index default unique List of common SQL keywords such as SELECT and JOIN SQL Why reinvent the wheel? Astro DB speaks the familiar, universal database language: SQL. User. id integer name string org string Code snippet demonstrating TypeScript autocompletion for a User schema TypeScript ORM Includes a modern, TypeScript ORM with type-safety and autocomplete on every query. Export database Export as SQL Export as CSV "Export data" button with a dropdown that says "Export as SQL" and "Export as CSV" Zero lock-in It's your data. Export it anytime, in the format you need. Visual Data Viewers Explore your data in a visual spreadsheet, a rich-text editor, or raw SQL console. Illustration of a bable-based user interface, similar to that of Excel Global Distribution Create databases in 8 different regions around the world, including the EU and Japan. A spinning globe with markers in 8 regions around the world Schema management Your schema lives in your codebase, with automatic schema diffing and migrations. Instant local development Develop locally with zero dependencies. No Docker? No problem. Webhooks Changes to data trigger webhooks that can integrate with most third-party tools. GitHub Automation Easy-to-use simplicity meets powerful scalability, with a visual UI that will save you time. Pricing Get started for free, then pay as you grow. Base Plan Get started for free $0 / month * Generous free tier * No credit card required * Database Unlimited * Applications Unlimited * Storage 1GB included, per month $1.00 per each additional 1GB * Row Reads One billion included, per month $0.001 per each additional 1M * Row Writes One million included, per month $1.00 per each additional 1M Start building with Astro DB today astro add db Copied! --------------------------------------------------------------------- Let's keep in touch Enter your email to keep in the know with the latest updates from Astro. [ ] [Submit] Resources * Documentation * Starter templates * Themes * Integrations Ecosystem * Community * Showcase * Contributing About * Press * Telemetry * Partner with us! More links * Blog * Swag Shop * Wallpapers * Studio --------------------------------------------------------------------- Privacy Policy Terms of Service MIT License (c) 2024 Astro Contributors Go to Astro's GitHub repo Join the Astro community on Discord Follow Astro on Twitter Follow Astro on Mastodon