Skip to content

VirtusLab-Open-Source/astro-strapi-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Logo - Strapi Astro Loader

Astro x Strapi Starter

πŸ”— Live Demo

All-in-one starter combining Astro, Strapi CMS, TailwindCSS, and shadcn/ui with support for Strapi Astro Loader and Strapi Astro Blocks Field.


✨ Features

  • ⚑ Astro 6 - Latest version with ultra-fast static sites
  • πŸ“ Strapi CMS - Headless CMS for content management
  • 🧱 Strapi Astro Blocks Field - Modular & flexible content block system
  • πŸ”„ Strapi Astro Loader - Automatic content loading from Strapi
  • 🎨 TailwindCSS 4 - Modern utility-first CSS styling
  • 🧩 shadcn/ui - Pre-configured React component library (optional)
  • πŸŒ— Dark / Light mode - Toggle with system preference detection
  • πŸ”€ Tailwind / shadcn toggle - Live component showcase comparing both approaches
  • πŸ”€ Inter font - Self-hosted variable font via @fontsource
  • πŸ“± Responsive Design - Optimized for all devices
  • 🌐 TypeScript - Full type support

image


πŸ“– Table of Contents


πŸš€ Quick Start

1. Use a starter template

# NPM
npm create astro@latest -- --template VirtusLab-Open-Source/astro-strapi-starter

# Yarn
yarn create astro --template VirtusLab-Open-Source/astro-strapi-starter

2. Environment Variables Setup

Create a .env file in the root directory:

# Strapi Configuration
STRAPI_URL=http://localhost:1337
STRAPI_TOKEN=your_strapi_api_token_here

3. Run the Project

npm run dev

Open http://localhost:4321 in your browser.

πŸ—‚οΈ Project Structure

/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ blocks/                # Strapi block components (Astro + Tailwind)
β”‚   β”‚   β”‚   β”œβ”€β”€ BlockRenderer.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ TextBlock.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ QuoteBlock.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ MediaBlock.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ CTABlock.astro
β”‚   β”‚   β”‚   └── HeroBlock.astro
β”‚   β”‚   β”œβ”€β”€ tailwind/              # Pure Tailwind Astro components
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ Card.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ CardHeader.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ CardTitle.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ CardDescription.astro
β”‚   β”‚   β”‚   β”œβ”€β”€ CardContent.astro
β”‚   β”‚   β”‚   └── Badge.astro
β”‚   β”‚   β”œβ”€β”€ ui/                    # shadcn/ui React components
β”‚   β”‚   β”‚   β”œβ”€β”€ button.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ card.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ badge.tsx
β”‚   β”‚   β”‚   └── separator.tsx
β”‚   β”‚   β”œβ”€β”€ showcase/              # Side-by-side component demos
β”‚   β”‚   β”‚   β”œβ”€β”€ TailwindShowcase.astro
β”‚   β”‚   β”‚   └── ShadcnShowcase.tsx
β”‚   β”‚   β”œβ”€β”€ Toolbar.astro          # Sticky header with logo + toggles
β”‚   β”‚   β”œβ”€β”€ ThemeToggle.astro      # Dark / Light mode switch
β”‚   β”‚   └── UIToggle.astro         # Tailwind / shadcn switch
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   └── utils.ts               # cn() utility for class merging
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   └── index.astro            # Homepage
β”‚   β”œβ”€β”€ types/
β”‚   β”‚   └── strapi.ts              # TypeScript types for Strapi
β”‚   β”œβ”€β”€ content.config.ts          # Strapi Loader configuration
β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   └── global.css             # Theme, fonts, toggle visibility rules
β”‚   └── utils/
β”‚       └── media.ts               # Strapi Media utils
β”œβ”€β”€ components.json                # shadcn/ui configuration
β”œβ”€β”€ package.json
└── astro.config.mjs

πŸ† Lighthouse Score

Nearly perfect scores out of the box β€” no extra optimization needed.

Desktop Mobile
Lighthouse Desktop Lighthouse Mobile

πŸŒ— Dark / Light Mode

The starter includes a theme toggle in the header. It:

  • Detects system preference on first visit
  • Saves choice to localStorage
  • Renders an inline script in <head> to prevent flash of wrong theme
  • Toggles the dark class on <html> β€” all semantic tokens adapt automatically

All components use semantic color tokens (text-foreground, bg-card, border-border, etc.) so dark mode works everywhere out of the box.

🧩 UI Components: shadcn/ui vs Pure Tailwind

This starter ships with two parallel component sets β€” switch between them live using the toggle in the header.

Pure Tailwind (Astro)

Components in src/components/tailwind/ are .astro files styled with Tailwind utility classes. Zero JavaScript, server-rendered.

---
import Button from "@/components/tailwind/Button.astro";
import Card from "@/components/tailwind/Card.astro";
import CardHeader from "@/components/tailwind/CardHeader.astro";
import CardTitle from "@/components/tailwind/CardTitle.astro";
import CardContent from "@/components/tailwind/CardContent.astro";
---

<Card>
  <CardHeader>
    <CardTitle>My Card</CardTitle>
  </CardHeader>
  <CardContent>
    <Button variant="outline">Click me</Button>
  </CardContent>
</Card>

shadcn/ui (React)

Components in src/components/ui/ are React components built on Radix UI primitives. Accessible, composable, interactive.

---
import { Button } from "@/components/ui/button";
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
---

<Card>
  <CardHeader>
    <CardTitle>My Card</CardTitle>
  </CardHeader>
  <CardContent>
    <Button client:load variant="outline">Click me</Button>
  </CardContent>
</Card>

Adding More shadcn/ui Components

npx shadcn@latest add dialog dropdown-menu tabs

Removing shadcn/ui

If you prefer pure Tailwind only:

  1. Delete src/components/ui/, src/components/showcase/ShadcnShowcase.tsx, and src/lib/utils.ts
  2. Delete components.json
  3. Remove @astrojs/react from astro.config.mjs (if not using React elsewhere)
  4. Uninstall: npm uninstall @astrojs/react radix-ui class-variance-authority clsx tailwind-merge lucide-react tw-animate-css shadcn

πŸ“¦ Strapi Astro Packages

πŸ”¨ Available Commands

Command Action
npm install Installs dependencies
npm run dev Starts dev server at localhost:4321
npm run build Build your production site to ./dist/
npm run preview Preview your build locally
npm run astro ... Run CLI commands like astro add, astro check

🌍 Deploy

Vercel

  1. Connect your repository to Vercel
  2. Add environment variables in project settings
  3. Deploy!

Netlify

  1. Connect your repository to Netlify
  2. Set build command: npm run build
  3. Set publish directory: dist
  4. Add environment variables

πŸ“š Useful Links

πŸ”§ Development

  1. Clone the repository
  2. Install dependencies:
npm install
  1. Run development mode:
npm run dev
  1. Check types:
npx astro check

🀝 Contributing

We welcome contributions to this project! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please make sure to:

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Keep your PR focused and concise

πŸ“„ License

Copyright Β© Sensinum

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

The Astro x Strapi Starter template

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors