Astro Quickstart

Scenario 1

Build a page that shows a number stored in a database.

Option 1

Run a server (any common server-side language). On every request, fetch the number from the database and render HTML to return to the user.

SEO-friendly, but every request hits the DB, so it’s slower.

Server-side rendering flow

User request

The browser sends an HTTP request

HTTP request

Server

Receives the request

Query the data

Database

Query the data

Generate the HTML

Server

Generates the HTML

Return the response

Return the HTML

The browser renders the page

Characteristics

  • ✅ SEO friendly: the HTML contains the complete content
  • ⚠️ Lower performance: every request has to reach the database
  • ⚠️ Heavy server load: the HTML has to be generated on the fly

Option 2

Let Nginx return a static HTML shell; the page fetches the number from an API via JavaScript and updates the content.

Fast, but not SEO-friendly because the initial HTML has no number.

Static HTML + API flow

User request

The browser sends an HTTP request

Request the static HTML

Return the static HTML

nginx returns the HTML file directly

HTML + JavaScript

Execute the JavaScript

The browser runs the JS code

API request

Backend API

Handle the API request

Return the JSON data

Update the page

JavaScript updates the DOM

Characteristics

  • ✅ Good performance: static files are returned directly by nginx
  • ⚠️ Not SEO friendly: the initial HTML contains no data content
  • ⚠️ Two requests are needed: HTML + API

Scenario 2

A highly interactive site with many pages.

Common approach

Use a SPA with Vue/React, handling all pages and interactions on the client.

First load returns an empty HTML plus a large JS bundle; the browser downloads/executes to render and handle interactions.

Supports rich interactivity, but first load is heavy and SEO suffers. Every user downloads the JS and renders in the browser—expensive.

SPA loading flow

User request

The browser sends an HTTP request

Request the page

Return an empty HTML

Only the basic structure, no content

Download a large amount of JS

Download the JavaScript

Framework code + application code

Execute the JS code

Execute the JavaScript

The browser parses and runs the code

Render the page

The page is rendered

The user sees the complete page

Characteristics

  • ✅ Highly interactive: complex client-side interactions are possible
  • ⚠️ Slow first load: a large amount of JS code has to be downloaded
  • ⚠️ Not SEO friendly: the initial HTML is empty
  • ⚠️ High runtime cost: every user has to render the page in the browser

If everyone is rendering anyway, why not render on the server and send HTML directly?

The ideal approach

Do everything you can at build time; keep only essential interactive logic for runtime.

Astro build-time rendering

Build time

Fetch data at build time

Pull data from a database or API

Generate static HTML

Generate static HTML

Pre-render every page

Build finished, deploy the static files
Runtime

User request

The browser sends an HTTP request

Return the static HTML directly

Return the static HTML

It contains the complete content

Load only the necessary JS

The page shows immediately

Fast to load, SEO friendly

Advantages

  • ✅ SEO friendly: the HTML contains the complete content
  • ✅ Excellent performance: static files are returned directly, with no server-side processing
  • ✅ Fast loading: only the necessary JavaScript is loaded
  • ✅ Low server load: no HTML has to be generated on the fly
  • ✅ Highly scalable: CDN acceleration and worldwide distribution

Astro’s philosophy

“Content-first, build-time rendering.”

  • Default output is static HTML; no JS on first paint, great SEO.
  • Only truly interactive components hydrate on demand (partial hydration/islands).
  • Mix Vue/React/Svelte/Preact islands on the same page.

Quick start

  1. pnpm create astro@latest (or npm/yarn).
  2. Pick a template and install dependencies.
  3. Dev: pnpm dev, then open the shown URL.
  4. Build: pnpm build outputs to dist/ for static hosting (e.g., Cloudflare Pages).

When to use Astro

  • Content/docs/blog/marketing pages aiming for fast first paint and strong SEO.
  • Multi-framework pages that mix several component libraries.
  • You can still do SSR/API routes, but default to static and minimize dynamic parts.

Found an issue with this content?

Tell us what could be improved.