Skip to content
Astro Tutorial Web Development

Getting Started with Astro: A Complete Guide

Learn how to build lightning-fast websites with Astro, the modern static site generator that ships zero JavaScript by default.

Sarah Chen
Getting Started with Astro: A Complete Guide

Introduction

Astro is a modern static site generator that delivers lightning-fast performance by shipping zero JavaScript by default. In this comprehensive guide, we’ll explore how to get started with Astro and build your first project.

Why Choose Astro?

Astro offers several compelling advantages:

  • Zero JavaScript by default - Only ship the JavaScript you need
  • Component Islands - Use React, Vue, Svelte, or any framework
  • Content-focused - Built for content-rich websites
  • SEO-friendly - Static HTML output for better search rankings

Setting Up Your First Project

Getting started with Astro is straightforward. Run the following command:

npm create astro@latest my-project
cd my-project
npm run dev

Project Structure

A typical Astro project looks like this:

├── src/
│   ├── components/
│   ├── layouts/
│   ├── pages/
│   └── styles/
├── public/
├── astro.config.mjs
└── package.json

Creating Your First Page

Create a new file at src/pages/about.astro:

---
import Layout from '../layouts/Layout.astro';
---

<Layout title="About">
  <h1>About Us</h1>
  <p>Welcome to our website!</p>
</Layout>

Adding Components

Astro supports components from multiple frameworks. Here’s a simple Astro component:

---
const { title } = Astro.props;
---

<div class="card">
  <h2>{title}</h2>
  <slot />
</div>

Conclusion

Astro is an excellent choice for building fast, content-focused websites. Its unique approach to JavaScript and support for multiple frameworks makes it incredibly versatile.

Start building with Astro today and experience the difference!