An Astro SaaS website is a static marketing site (home, features, pricing, customers, blog and legal pages) that sits in front of your app, usually on the root domain while the product runs at app.example.com. Astro is a strong fit because it renders every page to HTML at build time, ships no JavaScript unless you opt in, and keeps content like customer stories and blog posts in typed Content Collections. This tutorial builds that site from scratch.
Key Takeaways
- Keep the marketing site separate from the app: static Astro on
example.com, the product onapp.example.com.- Model pricing plans, customer stories and blog posts as data or Content Collections, not hard-coded markup.
- A monthly and yearly pricing toggle needs about ten lines of plain script, not a framework.
- Add a sitemap, canonical URLs and Open Graph tags once in the layout and every page inherits them.
- The build is static, so hosting is cheap and there is no server to patch.
Plan the site structure
Most SaaS marketing sites need the same core pages. Plan them first, because the file tree in src/pages/ becomes your URL structure.
src/
├── components/ # Header, Footer, Hero, PricingTable, LogoStrip, Cta
├── content/
│ ├── blog/ # product and engineering posts (MDX)
│ └── customers/ # customer stories (Markdown)
├── data/
│ └── plans.ts # pricing plans
├── layouts/
│ └── Base.astro
└── pages/
├── index.astro
├── features.astro
├── pricing.astro
├── customers/
│ ├── index.astro
│ └── [id].astro
├── blog/
│ ├── index.astro
│ └── [id].astro
└── legal/
├── privacy.astro
└── terms.astro
Create the project and add the integrations you will use:
npm create astro@latest acme-site -- --template minimal
cd acme-site
npx astro add tailwind mdx sitemap
Build the shared layout
Every page uses one layout with the header, footer and SEO tags. The header’s “Sign in” and “Start free” buttons point to the app domain.
---
// src/layouts/Base.astro
import '../styles/global.css';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
interface Props {
title: string;
description: string;
}
const { title, description } = Astro.props;
const canonical = new URL(Astro.url.pathname, Astro.site);
---
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{title}</title>
<meta name="description" content={description} />
<link rel="canonical" href={canonical} />
<link rel="sitemap" href="/sitemap-index.xml" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={new URL('/og.png', Astro.site)} />
</head>
<body class="flex min-h-screen flex-col font-sans text-zinc-900">
<Header />
<main class="flex-1"><slot /></main>
<Footer />
</body>
</html>
---
// src/components/Header.astro
const nav = [
{ label: 'Features', href: '/features/' },
{ label: 'Pricing', href: '/pricing/' },
{ label: 'Customers', href: '/customers/' },
{ label: 'Blog', href: '/blog/' },
];
const current = Astro.url.pathname;
---
<header class="border-b border-zinc-200">
<nav class="mx-auto flex max-w-6xl items-center justify-between px-6 py-4" aria-label="Main">
<a href="/" class="font-bold">Acme</a>
<ul class="hidden gap-6 md:flex">
{nav.map((item) => (
<li>
<a href={item.href} aria-current={current.startsWith(item.href) ? 'page' : undefined}>{item.label}</a>
</li>
))}
</ul>
<div class="flex gap-3">
<a href="https://app.example.com/login">Sign in</a>
<a href="https://app.example.com/signup" class="rounded-lg bg-indigo-600 px-4 py-2 text-white">Start free</a>
</div>
</nav>
</header>
Set site: 'https://example.com' and trailingSlash: 'always' in astro.config.mjs so canonical URLs and the sitemap match your links. The trailing slash tip explains why consistency matters.
Model pricing as data
Pricing changes more than any other page. Put plans in a typed file so the pricing page, the home page teaser and any comparison table read from one source.
// src/data/plans.ts
export interface Plan {
name: string;
monthly: number;
yearly: number;
blurb: string;
features: string[];
cta: string;
highlight?: boolean;
}
export const plans: Plan[] = [
{ name: 'Starter', monthly: 12, yearly: 120, blurb: 'For solo builders.', features: ['3 projects', 'Community support'], cta: 'Start free' },
{ name: 'Growth', monthly: 39, yearly: 390, blurb: 'For growing teams.', features: ['Unlimited projects', 'SSO', 'Priority support'], cta: 'Start trial', highlight: true },
{ name: 'Enterprise', monthly: 0, yearly: 0, blurb: 'Custom contracts.', features: ['Audit logs', 'Dedicated support'], cta: 'Contact sales' },
];
Build the pricing page with a billing toggle
The toggle swaps displayed prices. Both prices are rendered into the HTML at build time, and a short script flips which one is visible. Search engines and visitors without JavaScript still see the monthly price.
---
// src/components/PricingTable.astro
import { plans } from '../data/plans';
---
<div class="pricing" data-billing="monthly">
<div role="group" aria-label="Billing period" class="flex justify-center gap-2">
<button type="button" data-set="monthly" aria-pressed="true">Monthly</button>
<button type="button" data-set="yearly" aria-pressed="false">Yearly (2 months free)</button>
</div>
<div class="mt-10 grid gap-6 md:grid-cols-3">
{plans.map((plan) => (
<article class:list={['rounded-2xl border p-8', plan.highlight && 'border-indigo-600 ring-2 ring-indigo-600']}>
<h2 class="text-lg font-semibold">{plan.name}</h2>
<p class="text-zinc-600">{plan.blurb}</p>
{plan.monthly > 0 ? (
<p class="mt-4 text-4xl font-bold">
<span class="price-monthly">${plan.monthly}/mo</span>
<span class="price-yearly">${plan.yearly}/yr</span>
</p>
) : (
<p class="mt-4 text-4xl font-bold">Custom</p>
)}
<ul class="mt-6 space-y-2">{plan.features.map((f) => <li>{f}</li>)}</ul>
<a href="https://app.example.com/signup" class="mt-8 block rounded-lg bg-zinc-900 py-3 text-center text-white">{plan.cta}</a>
</article>
))}
</div>
</div>
<style>
.pricing[data-billing='monthly'] .price-yearly,
.pricing[data-billing='yearly'] .price-monthly {
display: none;
}
</style>
<script>
document.querySelectorAll<HTMLElement>('.pricing').forEach((root) => {
root.querySelectorAll<HTMLButtonElement>('[data-set]').forEach((btn) => {
btn.addEventListener('click', () => {
root.dataset.billing = btn.dataset.set;
root.querySelectorAll('[data-set]').forEach((b) => b.setAttribute('aria-pressed', String(b === btn)));
});
});
});
</script>
Astro bundles the script once per page and the CSS is scoped to this component. For a more complete pattern with annual savings badges, see the Astro pricing table component.
Customer stories as a Content Collection
Customer stories are the strongest proof on a SaaS site. Each one is a Markdown file with structured frontmatter, so the index page can show logos and headline results while each story gets its own URL.
// src/content.config.ts
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';
const customers = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/customers' }),
schema: ({ image }) =>
z.object({
company: z.string(),
industry: z.string(),
logo: image(),
result: z.string(), // e.g. "Cut deploy time from 40 to 6 minutes"
quote: z.string().optional(),
pubDate: z.coerce.date(),
}),
});
const blog = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: './src/content/blog' }),
schema: z.object({
title: z.string(),
description: z.string(),
pubDate: z.coerce.date(),
}),
});
export const collections = { customers, blog };
---
// src/pages/customers/[id].astro
import { getCollection, render } from 'astro:content';
import { Image } from 'astro:assets';
import Base from '../../layouts/Base.astro';
export async function getStaticPaths() {
const stories = await getCollection('customers');
return stories.map((story) => ({ params: { id: story.id }, props: { story } }));
}
const { story } = Astro.props;
const { Content } = await render(story);
---
<Base title={`${story.data.company} customer story`} description={story.data.result}>
<article class="prose mx-auto max-w-3xl px-6 py-16">
<Image src={story.data.logo} alt={story.data.company} height={48} />
<h1>{story.data.result}</h1>
<Content />
</article>
</Base>
The blog uses the same pattern. Only publish real stories with permission from the customer; invented testimonials damage trust and can break advertising rules. The Content Collections guide covers schemas, image() and sorting.
Features page and home page
The home page reuses components: a hero, a logo strip read from the customers collection, a three-feature summary, a pricing teaser from plans.ts, and a final call to action.
---
// src/pages/index.astro
import { getCollection } from 'astro:content';
import { Image } from 'astro:assets';
import Base from '../layouts/Base.astro';
import Hero from '../components/Hero.astro';
import Cta from '../components/Cta.astro';
const customers = (await getCollection('customers')).slice(0, 6);
---
<Base title="Acme: Deploy Previews for Every Pull Request" description="Acme builds a live preview of every pull request so reviewers see the change, not the diff.">
<Hero />
<section aria-label="Customers" class="mx-auto flex max-w-6xl flex-wrap justify-center gap-10 px-6 py-12 opacity-80">
{customers.map((c) => <Image src={c.data.logo} alt={c.data.company} height={32} />)}
</section>
<Cta />
</Base>
Write the features page around problems, not adjectives. Each section should name a job the customer has (“review a change without pulling the branch”) and show how the product does it, ideally with a real screenshot processed by <Image />.
Demo requests and the app boundary
Keep forms simple. A “Book a demo” form can post to your CRM’s form endpoint or a form service, so the marketing site stays static. If you need server logic, such as checking a work email domain, add an adapter and a single on-demand route or Astro Action while the rest of the site stays prerendered. The Astro SSR guide shows how to mix static and on-demand pages.
Don’t put the application itself inside the marketing site. Separate deploys mean a marketing copy change can’t break the product, and the app team can pick any stack.
SEO, sitemap and deployment
With @astrojs/sitemap installed and site set, astro build writes sitemap-index.xml. Exclude pages such as /thanks/ with the integration’s filter option. Then:
npm run build
npx wrangler pages deploy dist # or connect the repo in Netlify or Vercel
Point the root domain at the static host and keep app. on your application host. The Cloudflare Pages deploy docs cover the setup, and the official Astro deployment guides list every host.
Starting from a SaaS template
If you’d rather customize than build, there are good free starting points, such as AstroWind and Astro’s official starters on astro.build/themes. Komal Nakrani’s Aegis Console theme is one paid example: it is built for a technical B2B product, with a security console drawn in CSS, pricing tiers that state what they don’t include, and customer stories as a content collection. You can view the Aegis Console theme or browse the technology category for other product sites.
FAQ
Is Astro good for SaaS websites?
Astro is a strong choice for the marketing side of a SaaS product: home, features, pricing, blog, docs and legal pages. It renders static HTML with no default JavaScript, which keeps pages fast and cheap to host. The logged-in application is usually a separate app on its own subdomain.
Can I build my SaaS app in Astro too?
You can build parts of an app with Astro’s on-demand rendering, Actions, sessions and framework islands, and some small products do. Most teams keep the marketing site in Astro and the interactive app in a separate deploy, so each can change without risking the other.
How do I add a pricing toggle in Astro without React?
Render both monthly and yearly prices into the HTML, hide one with CSS based on a data-billing attribute, and use a short <script> to switch the attribute when a button is clicked. It works without a framework and stays readable for search engines.
Should the SaaS blog be on a subdomain or a subfolder?
A subfolder such as /blog/ on the main domain is the common choice, because links and authority accrue to one site. With Astro the blog lives in the same project as a Content Collection, so a subfolder is also the simpler setup.
How do I connect sign-up buttons to my app?
Link the buttons straight to your app’s sign-up URL, such as https://app.example.com/signup. Add UTM parameters if you track campaigns. The marketing site doesn’t need to handle authentication at all.