Framework
Seed Next.js + Drizzle + Neon with MockHero
The Setup
Next.js App Router, Drizzle ORM, Neon serverless Postgres. Goal: realistic users, projects, and tasks with correct foreign keys.
// scripts/seed.ts
import { drizzle } from "drizzle-orm/neon-http";
import { neon } from "@neondatabase/serverless";
import { users, projects, tasks } from "@/db/schema";
const sql = neon(process.env.DATABASE_URL!);
const db = drizzle(sql);
const res = await fetch("https://api.mockhero.dev/api/v1/generate", {
method: "POST",
headers: { "x-api-key": process.env.MOCKHERO_API_KEY!, "Content-Type": "application/json" },
body: JSON.stringify({
tables: [
{ name: "users", count: 30, fields: [
{ name: "id", type: "uuid" },
{ name: "email", type: "email" }
]},
{ name: "projects", count: 80, fields: [
{ name: "id", type: "uuid" },
{ name: "owner_id", type: "ref", ref: "users.id" },
{ name: "name", type: "product_name" }
]},
{ name: "tasks", count: 400, fields: [
{ name: "id", type: "uuid" },
{ name: "project_id", type: "ref", ref: "projects.id" },
{ name: "title", type: "sentence" }
]}
]
})
});
const data = await res.json();
await db.insert(users).values(data.users);
await db.insert(projects).values(data.projects);
await db.insert(tasks).values(data.tasks);
Get Started
Create a free MockHero key and point your Drizzle seed script at it.
M
MockHero Team
Guides and tutorials for generating realistic test data with the MockHero API.
Start generating test data for free
1,000 rows/month on the free tier. No credit card required.
Get Your API Key