Deploy your Astro Site to Vercel
Ta treść nie jest jeszcze dostępna w Twoim języku.
You can use Vercel to deploy an Astro site to their global edge network with zero configuration.
This guide includes instructions for deploying to Vercel through the website UI or Vercel’s CLI.
Project configuration
Section titled Project configurationYour Astro project can be deployed to Vercel as a static site, or a server-rendered site.
Static site
Section titled Static siteYour Astro project is a static site by default. You don’t need any extra configuration to deploy a static Astro site to Vercel.
Adapter for on-demand rendering
Section titled Adapter for on-demand renderingAdd the Vercel adapter to enable on-demand rendering in your Astro project with the following astro add
command. This will install the adapter and make the appropriate changes to your astro.config.mjs
file in one step.
npx astro add vercel
pnpm astro add vercel
yarn astro add vercel
How to deploy
Section titled How to deployYou can deploy to Vercel through the website UI or using Vercel’s CLI (command line interface). The process is the same for both static and on-demand rendered Astro sites.
Website UI deployment
Section titled Website UI deployment-
Push your code to your online Git repository (GitHub, GitLab, BitBucket).
-
Import your project into Vercel.
-
Vercel will automatically detect Astro and configure the right settings.
-
Your application is deployed! (e.g. astro.vercel.app)
After your project has been imported and deployed, all subsequent pushes to branches will generate Preview Deployments, and all changes made to the Production Branch (commonly “main”) will result in a Production Deployment.
CLI deployment
Section titled CLI deployment-
Install the Vercel CLI and run
vercel
to deploy.Terminal window npm install -g vercelvercelTerminal window pnpm add -g vercelvercelTerminal window yarn global add vercelvercel -
Vercel will automatically detect Astro and configure the right settings.
-
When asked
Want to override the settings? [y/N]
, chooseN
. -
Your application is deployed! (e.g. astro.vercel.app)
Project config with vercel.json
Section titled Project config with vercel.jsonYou can use vercel.json
to override the default behavior of Vercel and to configure additional settings. For example, you may wish to attach headers to HTTP responses from your Deployments.