Setup Scripts
Seed your database with initial data for a complete CMS experience
Setup Scripts
The starter kit includes powerful seeding scripts to populate your database with mock data, giving you a complete CMS-like experience from day one.
Quick Setup
All-in-One Setup
The easiest way to get started:
pnpm project:setupThis single command:
- ✅ Validates environment variables
- ✅ Pushes database schema
- ✅ Seeds subscription plans
- ✅ Seeds blog content (categories, tags, welcome post)
- ✅ Seeds testimonials
- ✅ Seeds email templates
This is the recommended approach for first-time setup!
Individual Seed Scripts
You can also run each seeding script individually:
Database Schema
pnpm db:pushCreates all database tables based on your Drizzle schema.
Subscription Plans
pnpm plans:setupCreates:
- Free plan (tier)
- Pro plan ($19.99/month or $199/year)
- Startup plan ($49.99/month or $499/year)
Includes:
- Feature lists
- Pricing in cents
- Stripe Price IDs (if configured)
- Usage limits
Blog Content
pnpm blog:seedCreates:
- Categories: Getting Started, Tutorials, News, Updates
- Tags: Next.js, React, TypeScript, Web Development
- Welcome Post: A sample blog post to demonstrate the editor
Perfect for:
- Demonstrating the blog system
- Testing blog features
- Having example content for design
Testimonials
pnpm testimonials:seedCreates:
- Multiple sample testimonials
- Different ratings (4-5 stars)
- Approved status for immediate display
- Placeholder customer names and companies
Great for:
- Showing social proof on marketing pages
- Testing testimonial display
- Having sample data for the admin panel
Email Templates
pnpm email:seedCreates default templates for:
- Welcome email
- Email verification
- Password reset
- Subscription created
- Subscription canceled
- Invoice paid
Each template includes:
- HTML version
- Plain text version
- Variable placeholders (
{{userName}},{{appName}}, etc.) - Professional styling
Admin Setup
pnpm admin:setupPromotes the user with FIRST_ADMIN_EMAIL to admin role.
Requirements:
- Set
FIRST_ADMIN_EMAILin.env - Sign up with that email address
- Run this command
- Sign in again to access admin dashboard
Test Data for E2E Tests
pnpm test:seedCreates pre-configured test users:
- Regular test user
- Admin test user
Used for Playwright E2E tests.
What Gets Seeded
Blog System
- 4 categories with descriptions and slugs
- 8+ tags covering common topics
- 1 welcome post with rich content, featured image, and SEO
- Working author attribution
- Published and ready to display
Subscription Plans
- 3 pricing tiers (Free, Pro, Startup)
- Monthly and yearly pricing
- Feature lists for each tier
- Usage limits (storage, API calls, team members)
- Stripe integration ready
Testimonials
- 5-7 sample testimonials
- Real-looking customer names and companies
- 4-5 star ratings
- Approved status
- Ready to display on homepage
Email Templates
- 6 transactional email templates
- Professional HTML design
- Plain text fallbacks
- Variable substitution ready
- Active and ready to send
Manual Seeding
If you prefer to create your own data:
// scripts/my-seed.ts
import { db } from "../src/db";
import { blogCategories } from "../src/db/schema";
async function seed() {
await db.insert(blogCategories).values([
{
name: "My Category",
slug: "my-category",
description: "Custom category",
},
]);
console.log("✅ Seeding complete!");
}
seed();Run with:
tsx scripts/my-seed.tsWhen to Run Setup Scripts
First Time Setup
Run pnpm project:setup to get everything ready.
After Schema Changes
Run pnpm db:push to update database structure.
Adding New Features
Run individual seed scripts as needed:
- Added blog? →
pnpm blog:seed - Added testimonials? →
pnpm testimonials:seed
Before Demo/Testing
Run all seeds to have complete sample data.
Production Deployment
Don't run seed scripts in production! These are for development/testing only.
Instead:
- Create subscription plans via admin dashboard
- Write real blog posts
- Collect real testimonials
- Customize email templates
Customizing Seed Data
Edit Subscription Plans
Modify scripts/setup-subscription-plans.ts:
const plans = [
{
name: "Basic", // Change name
priceMonthly: 999, // $9.99/month
features: ["Your custom feature", "Another feature"],
},
// Add more plans...
];Edit Blog Categories
Modify scripts/seed-blog.ts:
const categories = [
{ name: "Your Category", slug: "your-category" },
// Add more...
];Edit Email Templates
Modify scripts/seed-email-templates.ts or use the admin dashboard's template editor after seeding.
Resetting Data
To start fresh:
# Drop all tables and recreate
pnpm db:push --force
# Re-run setup
pnpm project:setupThis deletes ALL data, including users and content!
Troubleshooting
"Table already exists" errors
The scripts are idempotent - they check if data exists before inserting. Safe to run multiple times.
Seed script fails
- Check
DATABASE_URLis correct - Ensure database is accessible
- Verify
pnpm db:pushcompleted successfully - Check console for specific error messages
No data appears after seeding
-
Verify script completed without errors
-
Check database directly:
# Connect to your database and query SELECT * FROM blog_categories; SELECT * FROM subscription_plans; -
Clear Next.js cache and restart:
rm -rf .next pnpm dev
Best Practices
- Run setup once - Don't repeatedly seed in development
- Customize after seeding - Edit seeded data via admin dashboard
- Production: manual setup - Don't seed production databases
- Test with seeds - Perfect for E2E tests and demos
- Document custom seeds - If you create custom seed scripts, document them
Available Scripts Reference
| Command | Purpose |
|---|---|
pnpm project:setup | Complete setup (recommended) |
pnpm db:push | Push database schema |
pnpm admin:setup | Promote first admin |
pnpm plans:setup | Seed subscription plans |
pnpm blog:seed | Seed blog content |
pnpm testimonials:seed | Seed testimonials |
pnpm email:seed | Seed email templates |
pnpm test:seed | Create test users |
Next Steps
After running setup scripts:
- Start dev server:
pnpm dev - View your site: http://localhost:3000
- Check the blog: http://localhost:3000/blog (see seeded post)
- Access admin: Create account and run
pnpm admin:setup - Customize data: Edit via admin dashboard
The setup scripts give you a complete, working application in minutes. Customize the seeded data to match your brand!