Next Starter Kit
Getting Started

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:setup

This single command:

  1. ✅ Validates environment variables
  2. ✅ Pushes database schema
  3. ✅ Seeds subscription plans
  4. ✅ Seeds blog content (categories, tags, welcome post)
  5. ✅ Seeds testimonials
  6. ✅ 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:push

Creates all database tables based on your Drizzle schema.

Subscription Plans

pnpm plans:setup

Creates:

  • 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:seed

Creates:

  • 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:seed

Creates:

  • 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:seed

Creates 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:setup

Promotes the user with FIRST_ADMIN_EMAIL to admin role.

Requirements:

  1. Set FIRST_ADMIN_EMAIL in .env
  2. Sign up with that email address
  3. Run this command
  4. Sign in again to access admin dashboard

Test Data for E2E Tests

pnpm test:seed

Creates 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.ts

When 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:setup

This 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

  1. Check DATABASE_URL is correct
  2. Ensure database is accessible
  3. Verify pnpm db:push completed successfully
  4. Check console for specific error messages

No data appears after seeding

  1. Verify script completed without errors

  2. Check database directly:

    # Connect to your database and query
    SELECT * FROM blog_categories;
    SELECT * FROM subscription_plans;
  3. Clear Next.js cache and restart:

    rm -rf .next
    pnpm dev

Best Practices

  1. Run setup once - Don't repeatedly seed in development
  2. Customize after seeding - Edit seeded data via admin dashboard
  3. Production: manual setup - Don't seed production databases
  4. Test with seeds - Perfect for E2E tests and demos
  5. Document custom seeds - If you create custom seed scripts, document them

Available Scripts Reference

CommandPurpose
pnpm project:setupComplete setup (recommended)
pnpm db:pushPush database schema
pnpm admin:setupPromote first admin
pnpm plans:setupSeed subscription plans
pnpm blog:seedSeed blog content
pnpm testimonials:seedSeed testimonials
pnpm email:seedSeed email templates
pnpm test:seedCreate test users

Next Steps

After running setup scripts:

  1. Start dev server: pnpm dev
  2. View your site: http://localhost:3000
  3. Check the blog: http://localhost:3000/blog (see seeded post)
  4. Access admin: Create account and run pnpm admin:setup
  5. 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!

On this page