Below are the steps to deploy your Astro project to Vercel.
Step 1: Install Vercel CLI
First, install the Vercel CLI globally if you haven’t already:
npm install -g vercel
Step 2: Login to Vercel
Authenticate your CLI with your Vercel account:
vercel login
Step 3: Deploy the Project
Navigate to your project’s root directory and run the deploy command:
vercel
Deploying to Netlify
Here’s how you can deploy your Astro project to Netlify.
Step 1: Install Netlify CLI
Begin by installing the Netlify CLI globally:
npm install -g netlify-cli
Step 2: Login to Netlify
Authenticate your CLI with your Netlify account:
netlify login
Step 3: Update astro.config.mjs for Netlify
Replace the Vercel adapter with Netlify’s adapter in your astro.config.mjs:
import netlify from '@astrojs/netlify';import mdx from '@astrojs/mdx';import react from '@astrojs/react';import tailwind from '@astrojs/tailwind';import { defineConfig } from 'astro/config';import astroDocs from './integrations/astroDocs';export default defineConfig({output: 'hybrid',adapter: netlify({ functions: { // Optional: Specify the directory for Netlify Functions directory: 'netlify/functions', },anchors: [ { //rest of the file ]}
Step 4: Build and Deploy
Run the build command to generate the dist directory:
npm run build
Deploy the project to Netlify:
netlify deploy --prod --dir=dist
Follow the prompts to complete the deployment. Netlify will automatically handle the rest.