
Astro DB Has a Free API You're Not Using
Astro DB is a fully-managed SQL database built into Astro. It's powered by LibSQL (Turso) and gives you type-safe database access with zero configuration. The Free APIs You're Missing 1. Schema Definition — TypeScript-First // db/config.ts import { defineDb , defineTable , column } from " astro:db " ; const Post = defineTable ({ columns : { id : column . number ({ primaryKey : true }), title : column . text (), slug : column . text ({ unique : true }), content : column . text (), published : column . boolean ({ default : false }), authorId : column . number ({ references : () => Author . columns . id }), createdAt : column . date ({ default : new Date () }), }, }); const Author = defineTable ({ columns : { id : column . number ({ primaryKey : true }), name : column . text (), email : column . text ({ unique : true }), }, }); export default defineDb ({ tables : { Post , Author } }); Full type inference from schema. No codegen step. 2. Seeding — Type-Safe Data Loading // db/seed.ts impor
Continue reading on Dev.to JavaScript
Opens in a new tab

