Skip to content
/ astro-shadcn Public template

Build beautiful websites with Astro 5, shadcn/ui and React

License

Notifications You must be signed in to change notification settings

agentc-app/astro-shadcn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Astro 5 + Shadcn/UI Starter Kit

A lightning-fast starter template combining Astro's performance with Shadcn's beautiful components.

🎨 Screenshots

Dark Mode Light Mode

⚑ Quick Start

# Clone the repository
git clone https://github.com/agentc-app/astro-shadcn.git

# Navigate to project
cd astro-shadcn

# Install dependencies
npm install

# Start development server
npm run dev

Visit http://localhost:4321 - You're ready to go! πŸŽ‰

🎨 Pre-installed Components

All Shadcn/UI components are pre-configured for Astro:

---
// Example usage in .astro file
import { Button } from "@/components/ui/button"
import { Card } from "@/components/ui/card"
---

<Button>Click me!</Button>

Available Components

  • βœ… Accordion
  • βœ… Alert Dialog
  • βœ… Avatar
  • βœ… Badge
  • βœ… Button
  • βœ… Card
  • βœ… Dialog
  • ... and more!

πŸ› οΈ Project Structure

your-project/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   └── ui/          # All Shadcn components
β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   └── Layout.astro # Base layout
β”‚   └── pages/
β”‚       └── index.astro  # Homepage
β”œβ”€β”€ astro.config.mjs     # Astro configuration
└── tailwind.config.cjs  # Tailwind configuration

πŸ”§ Configuration

Astro is Setup

// astro.config.mjs
import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
import react from '@astrojs/react';

export default defineConfig({
  integrations: [
    tailwind(),
    react(), // Required for Shadcn components
  ],
  // Error suppression
  vite: {
    build: {
      suppressWarnings: true,
    }
  }
});

Using Components

---
// src/pages/index.astro
import { Button } from "@/components/ui/button";
import { Card, CardHeader, CardTitle } from "@/components/ui/card";
---

<Card>
  <CardHeader>
    <CardTitle>Welcome to Astro + Shadcn!</CardTitle>
  </CardHeader>
  <Button client:load>Interactive Button</Button>
</Card>

πŸš€ Development Workflow

  1. Start Development

    npm run dev
  2. Using React Components in Astro

    ---
    // Always add client:load for interactive components
    import { Dialog } from "@/components/ui/dialog"
    ---
    
    <Dialog client:load>
      <!-- Dialog content -->
    </Dialog>
  3. Build for Production

    npm run build
    npm run preview # Test the production build

πŸ” Troubleshooting

Common Issues Solved

βœ… Component Hydration: All interactive components use client:load βœ… Build Warnings: Suppressed in configuration βœ… Path Aliases: Pre-configured for easy imports βœ… React Integration: Properly set up for Shadcn

Quick Fixes

  1. Clear Cache

    rm -rf dist node_modules .astro
    npm install
  2. Restart Dev Server

    # Kill the dev server and restart
    npm run dev

πŸ’‘ Pro Tips

  1. Component Usage in Astro

    ---
    // Always import in the frontmatter
    import { Button } from "@/components/ui/button"
    ---
    
    <!-- Use in template -->
    <Button client:load>Click me!</Button>
  2. Styling with Tailwind

    <div class="dark:bg-slate-800">
      <Button class="m-4">Styled Button</Button>
    </div>
  3. Layout Usage

    ---
    import Layout from '../layouts/Layout.astro';
    ---
    
    <Layout title="Home">
      <!-- Your content -->
    </Layout>

πŸ“Š Performance & Screenshots

⚑ Lighthouse Scores

Desktop Performance Mobile Performance

Perfect scores across all metrics:

  • πŸš€ Performance: 100
  • β™Ώ Accessibility: 100
  • πŸ”§ Best Practices: 100
  • πŸ” SEO: 100

πŸ“š Quick Links

🀝 Need Help?


Built with πŸš€ Astro and 🎨 Shadcn/UI by AgentC