Prerequisites
Before you begin, ensure you have:- Node.js 18.17.1 or higher
- npm (comes with Node.js) or another package manager
- A code editor (VS Code recommended)
The project includes VS Code configuration in
.vscode/ for an optimal development experience.Initial Setup
Install dependencies
Navigate to your project directory and install the required packages:This installs Astro and any other dependencies defined in
package.json.Development Server
Starting the Server
Launch the development server with hot module replacement:Hot Module Replacement
Astro automatically reloads your changes:- Component changes - Updates instantly without full page reload
- Style changes - Injected without refresh
- Content changes - Page reloads to show new content
Development Options
Customize the dev server behavior:Building for Production
Create Production Build
Generate optimized static files:The
dist/ directory contains everything you need to deploy. Upload these files to any static hosting service.Build Output
After a successful build, you’ll see a summary:Preview Production Build
Test your production build locally before deploying:dist/:
Why Preview?
Test optimizations
Verify minification and bundling work correctly
Check routing
Ensure all links and routes function properly
Validate assets
Confirm images and static files load correctly
Performance testing
Measure actual load times and performance
Common Development Tasks
Adding a New Page
Create a new route by adding a file tosrc/pages/:
src/pages/about.astro
Adding Static Assets
Place files inpublic/ to serve them directly:
Using TypeScript
Astro supports TypeScript out of the box:src/pages/index.astro
Using the Astro CLI
Run Astro CLI commands directly:Troubleshooting
Port already in use
Port already in use
If port 4321 is occupied:
Changes not reflecting
Changes not reflecting
- Hard refresh your browser (Cmd+Shift+R or Ctrl+Shift+R)
- Restart the dev server
- Clear
.astro/cache:rm -rf .astro
Build errors
Build errors
Check for:
- Syntax errors in
.astrofiles - Missing imports
- TypeScript type errors
Module not found
Module not found
Reinstall dependencies:
Next Steps
Now that you’re comfortable with development:- Learn about deployment options
- Explore project structure
- Review configuration options