Building a Fast Content Site With Astro and Contentstack

Ship less JavaScript, load faster

Astro is a framework built for content-heavy websites. It renders pages to static HTML and ships JavaScript only for interactive "islands". Combined with Contentstack, it's a great fit for marketing sites and blogs.

Fetching Content

// src/lib/contentstack.js
import contentstack from '@contentstack/delivery-sdk';

export const stack = contentstack.stack({
  apiKey: import.meta.env.CS_API_KEY,
  deliveryToken: import.meta.env.CS_DELIVERY_TOKEN,
  environment: import.meta.env.CS_ENVIRONMENT,
});

Dynamic Routes

---
// src/pages/blog/[slug].astro
import { stack } from '../../lib/contentstack';

export async function getStaticPaths() {
  const res = await stack.contentType('blog_post').entry().find();
  return res.entries.map((post) => ({ params: { slug: post.url.replace('/blog/', '') }, props: { post } }));
}
const { post } = Astro.props;
---
<article>
  <h1>{post.title}</h1>
  <Fragment set:html={post.body_html} />
</article>

Islands for Interactivity

Add interactive components (search, carousels) only where needed with client:visible or client:idle. The rest stays static HTML.

Rebuilding on Publish

Set up a Contentstack webhook on publish that triggers a rebuild on your host (Contentstack Launch, Netlify, Vercel). For large sites, consider Astro's server rendering with caching instead of full rebuilds.

Why It Works

  • Excellent Core Web Vitals by default
  • SEO-friendly static HTML
  • Simple mental model for content teams

For content-first sites, Astro + Contentstack delivers speed with very little complexity.

Arivanandhan Chitheshwaran