Installation
Installation Guide
Section titled “Installation Guide”This guide covers different ways to install and set up astro-basics depending on your use case.
System Requirements
Section titled “System Requirements”- Node.js: Version 18 or higher
- npm: Version 8 or higher (or yarn/pnpm equivalent)
- Git: For cloning the repository
Installation Options
Section titled “Installation Options”Full Project Setup
Section titled “Full Project Setup”For complete project with all features, examples, and development tools:
# Clone the repositorygit clone https://github.com/shawn-sandy/astro-basics.git
# Navigate to project directorycd astro-basics
# Install dependencies (takes ~4 minutes)npm install
# Set up environmentcp .env.example .env
# Install pre-commit hooksnpm run prepare
# Install Playwright browsers (for E2E tests)npx playwright installComponent Library Only
Section titled “Component Library Only”To use astro-basics components in an existing Astro project:
npm install astro-basics-websitePost-Installation Setup
Section titled “Post-Installation Setup”1. Environment Configuration
Section titled “1. Environment Configuration”Edit your .env file with the required keys:
# Authentication (Required)PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your_key_hereCLERK_SECRET_KEY=sk_test_your_key_here
# Site URLSITE_URL=http://localhost:4321
# Database (Optional)SUPABASE_URL=https://your-project.supabase.coSUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# Turso (Optional)TURSO_DATABASE_URL=libsql://your-database.turso.ioTURSO_AUTH_TOKEN=your_auth_token_here2. Database Setup (Optional)
Section titled “2. Database Setup (Optional)”The project supports Supabase (PostgreSQL) and Turso (LibSQL) backends.
Interactive Setup (Recommended)
Section titled “Interactive Setup (Recommended)”# Use the database wizard for guided setupnpm run db:wizardThe wizard will detect available credentials and guide you through configuration.
Manual Setup
Section titled “Manual Setup”# Check database status and configurationnpm run db:status
# Initialize database schemanpm run db:setup
# Verify connectionnpm run db:check
# Run migrations (Supabase)npm run db:migrate
# Check migration statusnpm run db:migrate:statusDatabase Switching
Section titled “Database Switching”The project includes seamless database switching with automatic backups:
# Switch to Supabase (with backup)npm run db:switch:supabase
# Switch to Turso (with backup)npm run db:switch:turso
# Auto-detect and use available databasenpm run db:switch:auto
# Create backup onlynpm run db:backup
# Restore from backupnpm run db:restoreSee the Complete Setup Guide and Database Switching Guide for detailed configuration.
3. Role Configuration (Optional)
Section titled “3. Role Configuration (Optional)”The project includes a configurable role system for managing user permissions and access control.
Default Roles
Section titled “Default Roles”By default, astro-basics comes with a 3-tier role system:
- member (Level 1) - Default role for new users
- admin (Level 2) - Administrative access
- super_admin (Level 3) - Full system control
These roles are ready to use without any configuration.
Customizing Roles
Section titled “Customizing Roles”If you need custom roles for your application (e.g., author, moderator, editor):
1. Edit the configuration file:
vim config/roles.config.ts2. Add or modify roles:
export const roleConfig: RoleConfig = { roles: [ { name: 'member', level: 1, label: 'Member' }, { name: 'author', level: 2, label: 'Author' }, // Custom { name: 'moderator', level: 3, label: 'Moderator' }, // Custom { name: 'admin', level: 4, label: 'Admin' }, { name: 'super_admin', level: 5, label: 'Super Admin' }, ], coreRoles: ['member', 'admin', 'super_admin'],}3. Generate types and migrations:
# Generate TypeScript types and database migrationsnpm run setup:roles
# Apply the migrationnpm run db:migrate4. Commit your changes:
git add config/ src/types/ scripts/migrations/git commit -m "Configure custom roles"See the Complete Setup Guide - Role Configuration and Configurable Roles Guide for detailed instructions and templates.
4. Verify Installation
Section titled “4. Verify Installation”Start the development server:
npm run startVisit http://localhost:4321 to see your site running.
Development Tools
Section titled “Development Tools”Code Quality
Section titled “Code Quality”# Run all linting and formattingnpm run fix:all
# Type checkingnpm run type-check
# Individual toolsnpm run lint # ESLintnpm run lint:styles # StyleLintnpm run format # PrettierTesting
Section titled “Testing”# Unit testsnpm test
# E2E testsnpm run test:e2e
# Test reportsnpm run test:e2e:reportBuild and Deploy
Section titled “Build and Deploy”# Production buildnpm run build
# Preview buildnpm run preview
# Deploy to Netlifynpm run deploy:prodComponent Usage
Section titled “Component Usage”In Astro Files
Section titled “In Astro Files”---import { Header, Footer } from 'astro-basics-website'---
<Header title="My Site" /><main> <!-- Your content --></main><Footer />With TypeScript
Section titled “With TypeScript”import type { Props } from 'astro-basics-website'
// Use component props with full type safetyTroubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”1. Installation takes too long
- Expected: npm install takes ~4 minutes
- Warnings during installation are normal
2. Authentication errors
- Ensure
PUBLIC_CLERK_PUBLISHABLE_KEYandCLERK_SECRET_KEYare set - Use dummy keys for build-only testing
3. E2E tests failing
- Run
npx playwright installto install browsers - Ensure dev server is running on port 4321
4. Build warnings
- getStaticPaths warnings in dynamic pages are expected
- These don’t affect functionality
Getting Help
Section titled “Getting Help”- Check the GitHub Issues
- Review the troubleshooting section (coming soon)
- Ensure you’re using the latest version
Next Steps
Section titled “Next Steps”After installation, explore these guides:
- Complete Setup - Full feature configuration (database, roles, security)
- Configurable Roles - Custom role system with templates and examples
- Role Guard Usage - Access control patterns and best practices
- Database Switching - Flexible backend selection
- Components - Explore available components