astro-dev
Original:🇺🇸 English
Translated
4 scriptsChecked / no sensitive code detected
Comprehensive Astro development with React, Tailwind v4, and Cloudflare Workers deployment
15installs
Added on
NPX Install
npx skill4agent add augurproject/augur-reboot-website astro-devTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Astro Development Skill
Overview
Comprehensive guide for building modern web applications with Astro, React, Tailwind CSS v4, and Cloudflare Workers deployment.
What This Skill Provides
Automation Scripts
- Project initialization - Bootstrap new Astro projects with best practices
- Content collections setup - Generate type-safe content schemas
- View Transitions integration - Add smooth page transitions automatically
Reference Documentation
- Cloudflare Workers - Workers-first deployment (NOT Pages)
- Cloudflare D1 - Serverless SQLite database integration
- React integration - Interactive islands and hydration strategies
- Tailwind CSS v4 - CSS-first configuration without config files
- Content Collections - Type-safe content management
- View Transitions - Smooth page animations
- GitHub Actions - CI/CD automation
Component Templates
- BaseLayout - Full page layout with header, footer, and View Transitions
- Card - Reusable card component with Tailwind styling
- Button - React button with variants and sizes
Quick Start
Initialize New Project
For Cloudflare Workers deployment (recommended):
bash
./scripts/init_astro_cloudflare.sh my-appCreates:
- Astro project with SSR
- React integration
- Tailwind CSS v4
- Cloudflare adapter configured
- wrangler.jsonc for Workers deployment
For standard static site:
bash
./scripts/init_astro_standard.sh my-siteAdd Content Collections
bash
python scripts/setup_content_collection.py blogCreates:
- directory
src/content/blog/ - Type-safe Zod schema in
src/content/config.ts - Example blog post
Collection types:
- - Blog posts with frontmatter
blog - - Documentation pages
docs - - Product data (JSON)
products
Add View Transitions
bash
python scripts/add_view_transitions.pyAutomatically adds View Transitions API to all layouts in .
src/layouts/Common Workflows
1. Create Astro + Cloudflare Workers Site
bash
# Initialize project
./scripts/init_astro_cloudflare.sh my-blog
cd my-blog
# Set up content collections
python ../scripts/setup_content_collection.py blog
# Add View Transitions
python ../scripts/add_view_transitions.py
# Start development
npm run dev
# Deploy to Cloudflare Workers
npx wrangler deploy2. Add D1 Database
See for:
references/cloudflare-d1.md- Database creation
- Schema definition
- Query patterns
- Drizzle ORM integration
3. Build Interactive Components
See for:
references/react-integration.md- Client directives (load, idle, visible)
- Hooks and state management
- Form handling
- Context API
4. Style with Tailwind v4
See for:
references/tailwind-setup.md- CSS-first configuration
- Custom themes
- Dark mode
- OKLCH colors
- Container queries
Deployment
Cloudflare Workers (Recommended)
bash
# One-time setup
npm install -g wrangler
wrangler login
# Deploy
npm run build
npx wrangler deployKey points:
- Uses configuration
wrangler.jsonc - Deploys to Cloudflare Workers (NOT Pages)
- Main entry:
./dist/_worker.js - Static assets served from
./dist
See for:
references/cloudflare-workers.md- Bindings (KV, D1, R2)
- Environment variables
- TypeScript types
- SSR configuration
GitHub Actions
See for:
references/github-actions.md- Automated deployments
- Preview deployments for PRs
- Security scanning
- Performance budgets
Key Concepts
Rendering Modes
javascript
// astro.config.mjs
// Server-Side Rendering (all pages on-demand)
export default defineConfig({
output: 'server',
});
// Hybrid (static by default, opt-in to SSR)
export default defineConfig({
output: 'hybrid',
});
// Static (pre-rendered at build time)
export default defineConfig({
output: 'static',
});File Structure
my-astro-app/
├── src/
│ ├── pages/ # File-based routing
│ │ ├── index.astro
│ │ ├── blog/
│ │ │ └── [...slug].astro
│ │ └── api/ # API endpoints
│ │ └── data.ts
│ ├── layouts/ # Page layouts
│ │ └── BaseLayout.astro
│ ├── components/ # Astro components
│ │ └── Card.astro
│ ├── components/ # React components
│ │ └── Button.tsx
│ ├── content/ # Content collections
│ │ ├── config.ts
│ │ └── blog/
│ ├── styles/ # Global CSS
│ │ └── global.css
│ └── env.d.ts # TypeScript types
├── public/ # Static assets
│ └── .assetsignore # Workers asset config
├── astro.config.mjs # Astro configuration
├── wrangler.jsonc # Cloudflare Workers config
├── package.json
└── tsconfig.jsonClient Directives
Control when React components hydrate:
astro
<!-- Hydrate immediately -->
<Counter client:load />
<!-- Hydrate when idle -->
<SocialShare client:idle />
<!-- Hydrate when visible -->
<Comments client:visible />
<!-- Hydrate on specific media query -->
<MobileMenu client:media="(max-width: 768px)" />
<!-- Client-only (no SSR) -->
<BrowserWidget client:only="react" />Cloudflare Runtime
Access Workers APIs in pages and API routes:
astro
---
// In .astro files
const { env, cf, ctx } = Astro.locals.runtime;
// Use KV
const data = await env.MY_KV.get('key');
// Use D1
const { results } = await env.DB.prepare('SELECT * FROM users').all();
// Request properties
const country = cf.country;
---Best Practices
Performance
- Use SSG when possible - Pre-render static content
- Optimize images - Use Astro's component
<Image /> - Minimize client JS - Use React only where needed
- Leverage edge caching - Set cache headers on API routes
- Use KV for caching - Cache expensive operations
Development
- Type everything - Use TypeScript for better DX
- Validate content - Use Zod schemas for content collections
- Test locally - Use for bindings in dev
platformProxy - Generate types - Run after binding changes
wrangler types - Follow conventions - Use file-based routing
Deployment
- Deploy to Workers - Use Workers, not Pages (Cloudflare recommendation)
- Use environments - staging/production in wrangler.jsonc
- Automate with CI/CD - GitHub Actions for deployments
- Monitor performance - Use Cloudflare Analytics
- Review logs - Use for debugging
wrangler tail
Troubleshooting
Common Issues
Build Errors:
- Run for TypeScript errors
npx astro check - Check Node.js version (18+)
- Clear cache and rebuild
.astro
Hydration Issues:
- Ensure React components have directive
client:* - Check for SSR-incompatible code (browser APIs)
- Use if component can't be server-rendered
client:only
Deployment Issues:
- Verify configuration
wrangler.jsonc - Check permissions
CLOUDFLARE_API_TOKEN - Ensure bindings are configured correctly
- Review logs
wrangler tail
Tailwind Not Working:
- Import in layout
global.css - Verify Vite plugin in
astro.config.mjs - Check at top of CSS
@import "tailwindcss"
Resources
Documentation
Tools
Reference Files
- - Workers deployment guide
cloudflare-workers.md - - D1 database setup
cloudflare-d1.md - - React patterns
react-integration.md - - Tailwind v4 config
tailwind-setup.md - - Content management
content-collections.md - - Page animations
view-transitions.md - - CI/CD workflows
github-actions.md
Updating This Skill
Astro and its ecosystem evolve rapidly. To update:
- Search for latest Astro documentation
- Update reference files with new patterns
- Add new scripts for common workflows
- Test changes with real projects
- Repackage the skill
Version Information
This skill is current as of:
- Astro 5.x
- React 19.x
- Tailwind CSS 4.x
- Cloudflare Workers (latest)
- @astrojs/cloudflare 11.x+
Last updated: October 2024
Notes
- Cloudflare Workers, NOT Pages - This skill focuses exclusively on Workers deployment
- Tailwind v4 - Uses CSS-first configuration (no tailwind.config.js)
- Type-safe - Leverages TypeScript throughout
- Modern stack - Latest versions and best practices