#How to add astro db to vercel
4 messages · Page 1 of 1 (latest)
Hi @deft prawn. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To add Astro DB to your Astro project and deploy it on Vercel, you need to follow these steps:
-
Add Astro DB to your project:
You can use theastro addcommand to automate the setup of official integrations like Astro DB. Run one of the following commands in a new terminal window:npx astro add dbor
pnpm astro add dbor
yarn astro add dbIf you prefer to set things up manually, you can install Astro DB yourself. First, install the integration from npm via a package manager:
npm install @astrojs/dbor
pnpm add @astrojs/dbor
yarn add @astrojs/dbThen, add the integration to
astro.config.mjs:import { defineConfig } from 'astro/config'; import db from '@astrojs/db'; export default defineConfig({ integrations: [ db() ]});Finally, configure your database by creating a
db/config.tsfile at the root of your project. This is a special file that Astro will automatically load and use to configure your database tables:import { defineDb } from 'astro:db'; export default defineDb({ tables: {},})Source (https://docs.astro.build/en/guides/integrations-guide/db#installation)
-
Deploy your project to Vercel:
You can deploy your project to Vercel either by CLI (vercel deploy) or by connecting your new repo in the Vercel Dashboard (https://vercel.com/). Alternatively, you can create a production build locally:astro build vercel deploy --prebuiltSource (https://docs.astro.build/en/guides/integrations-guide/vercel#usage)