The Astro CLI
If you have run next dev you already know the pattern. Astro ships a single astro binary that handles every stage of the development lifecycle — development server, production build, local preview, integration scaffolding, and type checking. It maps almost exactly to the Next.js CLI commands you already use daily.
Core commands
Section titled “Core commands”# Start the dev server (hot module reloading, port 4321 by default)npx astro dev
# Production build → dist/npx astro build
# Serve the dist/ folder locally (mirrors the production build exactly)npx astro preview
# Add an official integration and update astro.config.mjs automaticallynpx astro add reactnpx astro add tailwindnpx astro add sitemap
# Type-check all .astro and .ts filesnpx astro checkpackage.json scripts
Section titled “package.json scripts”Both frameworks follow the same convention of aliasing the CLI commands to short script names.
// package.json — Next.js project{ "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint", "type-check": "tsc --noEmit" }}// package.json — Astro project{ "scripts": { "dev": "astro dev", "build": "astro build", "preview": "astro preview", "check": "astro check" }}Two things stand out:
astro previewis the local preview server — it is not a production server. Use an adapter (Node, Vercel, Cloudflare) for real production SSR.astro checkreplaces the two-steptsc --noEmit+ linter that Next.js projects typically maintain separately.
The astro add command
Section titled “The astro add command”npx astro add scaffolds official integrations in one step: it installs the npm package, updates astro.config.mjs, and prints what changed.
# Add the React integration (enables .tsx islands)npx astro add react
# Add Tailwind CSSnpx astro add tailwind
# Add the Vercel SSR adapternpx astro add vercel
# Add multiple at oncenpx astro add react tailwind sitemapThere is no Next.js equivalent for this — in Next you npm install a package, then manually update next.config.js. The astro add command automates the config step.
CLI flags
Section titled “CLI flags”# Custom portastro dev --port 3000
# Bind to all interfaces (useful in Docker / WSL)astro dev --host
# Verbose output during buildastro build --verbose
# Watch mode for astro check (re-runs on file save)astro check --watch