Usage
Commands
astro dev
Runs Astro’s development server. This starts a local HTTP server that serves your project with Hot Module Replacement (HMR).
Specifies which port to run on. If the port is already in use, Astro will automatically try the next available port.
Sets which network IP addresses the dev server should listen on (i.e. non-localhost IPs). Use
--host to expose the server on all addresses, or pass a specific IP.Opens the app in a browser on server start. Pass a URL path (e.g.
--open /about) to open to a specific page.Comma-separated list of allowed hostnames for the dev server.
astro build
Builds your site for production. By default, this will generate static files and place them in a dist/ directory. If SSR is enabled, this will generate the necessary server files to serve your site.
Specifies the output directory for the build. Overrides the
outDir config option.astro preview
Starts a local server to serve your built dist/ directory. This is useful for previewing your build locally, before deploying it.
Specifies which port to run on.
Sets which network IP addresses the preview server should listen on.
Opens the app in a browser on server start.
astro check
Runs diagnostics (such as type-checking .astro files) against your project and reports errors to the console. If any errors are found, the process will exit with a code of 1.
--watch
Runs the type checker in watch mode, re-checking files when they change.
astro sync
Generates TypeScript types for all Astro modules. This sets up type stubs for content collections, environment variables, and other Astro features.
astro add
Adds an integration to your Astro project. This command will:
- Install the integration package
- Update your
astro.config.mjsfile - Install any peer dependencies
react- React supportvue- Vue supportsvelte- Svelte supportsolid-js- Solid supportpreact- Preact supportmdx- MDX supporttailwind- Tailwind CSS supportsitemap- Sitemap generationpartytown- Partytown integration
netlify- Deploy to Netlifyvercel- Deploy to Vercelcloudflare- Deploy to Cloudflarenode- Deploy to Node.js serversdeno- Deploy to Deno Deploy
astro docs
Opens the Astro documentation website directly from your terminal.
astro info
Reports useful information about your current Astro environment. Useful for providing information when opening an issue.
- Astro version
- Node version
- Package manager
- Operating system
- Installed integrations
--copy
Automatically copies the info output to your clipboard.
astro preferences
Manage user preferences for Astro. Preferences are specific to individual Astro users, unlike the astro.config.mjs file which changes behavior for everyone working on a project.
devToolbar- Enable or disable the dev toolbar
--global
Set preferences globally for all Astro projects on your machine.
astro telemetry
Sets telemetry configuration for the current CLI user. Telemetry is anonymous data that provides insights into which Astro features are most used.
astro db
Commands for managing Astro DB. These commands require the @astrojs/db integration to be installed.
Global Flags
These flags are available for all commands:--config
Specifies the path to the config file. Defaults to
astro.config.mjs.--root
Specifies the path to the project root. If not specified, the current working directory is assumed to be the root.
--site
Overrides the
site configuration option.--base
Overrides the
base configuration option.--verbose
--verbose
Enables verbose logging, which is helpful when debugging an issue.
--silent
--silent
Enables silent logging, which will prevent all logging.
--version
--version
Prints the Astro version number and exits.
--help
--help
Prints help message and exits.
Environment Variables
The Astro CLI respects several environment variables:NODE_ENV
Sets the environment mode. Defaults to development in astro dev, and production in astro build and astro preview.
ASTRO_TELEMETRY_DISABLED
When set to 1, disables telemetry collection.