Start an Astro project
Develop, build, and preview
Use each Astro command for its intended stage and run the production build before deployment.
8 minute lesson
The three main commands answer different questions.
npm run dev
The development server favors fast feedback. A route is rendered when you open it locally.
npm run build
The production build checks imports and creates deployable output. In a static project, every known route is rendered to files under dist/ by default.
npm run preview
Preview serves the built output locally. It lets you inspect the generated routes and assets without rebuilding on every request.
Development success is not build success. A dynamic route may be missing a path. A content entry may fail its schema. A source filename may differ only by case.
Preview is also not the real host. Redirect status codes, headers, and server routes can depend on the platform.
Run all three commands. Write down when the page code ran in each mode.
Lesson completed