Deploying Astro to Vercel — What Nobody Tells You

Vercel deploys Astro in one click. But there are a few things that catch people out the first time.

Published June 18, 2026
Vercel deployment dashboard

Vercel and Astro work well together. Connect your GitHub repo, Vercel detects Astro automatically, deploys on every push. Takes about 2 minutes to set up.

But there are things that catch people out.

The adapter requirement

For a fully static Astro site, no adapter is needed. But the moment you add any server-side feature — API routes, server-rendered pages, middleware — you need @astrojs/vercel.

npx astro add vercel

This changes the build output from dist/ to a Vercel-specific structure. Static files go to dist/client/. This matters if you’re running post-build scripts — they need to target dist/client/, not dist/.

Environment variables

Vercel’s environment variables are available at build time and runtime. But Astro’s static build only has access to variables prefixed with PUBLIC_ on the client side.

Server-side variables (API keys, secrets) work normally in server-rendered routes and middleware. Never in static pages.

Preview deployments

Every pull request gets a preview deployment URL. Useful for reviewing content changes before merging to main. Free on Vercel’s hobby plan.

Steven Doan

Written by

Steven Doan

Freelance web developer. 10+ years building WordPress sites. Now learning Astro in public.

Follow me:

Stay in the loop

New articles on Astro, WordPress, and the modern stack. No spam. Unsubscribe anytime.

UI only — backend coming in a later article.

Related Posts

📦 This is a live demo project

Built step by step in the series Learn Astro from Scratch — read the full guide on doancongtuan.com.