Generating starter template
The user wants a boilerplate for a Next.js project with Prisma and Tailwind CSS, ideally using Next.js version 14 with TypeScript, PostgreSQL, and an app router. They’re looking for a concise starter template that includes essential files and a structure that resembles a GitHub repository. I should provide code snippets and layout while keeping it minimal yet comprehensive, featuring key files like package.json, next.config.js, and the structure for Prisma integration as well. Let's outline that!Creating a minimal template
The user requested a starter template without a usage example, but I think including at least one Prisma query example is useful. I want to keep the template concise while providing enough details. Assuming we're using Next.js with the App Router, I’ll structure it with essential files like package.json, tsconfig.json, and Prisma directories.
I’ll show code blocks for each file and mention installation commands. For package.json versioning, I could opt for something stable like ^14.1.0 or "latest" for simplicity without causing version mismatches later on. Let's get that organized!Finalizing dependencies and config
The user will eventually run npm install, which will pull the latest versions, so I think using "latest" for dependencies like Next.js, React, TypeScript, Tailwind CSS, and Prisma works well. I should add scripts in package.json for development and Prisma commands.
Since they want a starter template, including ESLint seems helpful, and I’ll set "prisma" as a devDependency while keeping "@prisma/client" as a regular dependency. I’ll also configure the Tailwind CSS file structure properly in the tailwind.config.ts, ensuring it picks up the necessary files and directives. Let’s make this efficient!Choosing the database provider
For the Prisma schema, I need to set the provider to "postgresql" with the environment variable env("DATABASE_URL"). While SQLite is easier for a minimal starter setup, I believe PostgreSQL is a better choice for a real-world application. Although users might prefer SQLite to avoid running a database, I think PostgreSQL is common with Prisma, making it more practical.
Still, I’ll provide a comment in the template to note that they can switch to SQLite if needed. I'll keep instructions brief, emphasizing the DATABASE_URL setup in the .env file.Building the starter template
Alright, I want to structure a minimal Next.js, Prisma, and Tailwind CSS starter template. We need several components like a Prisma client setup, a user route, and proper configurations. The Prisma schema will use PostgreSQL, and I’ll show how to implement the necessary files such as src/lib/prisma.ts and src/app/api/users/route.ts.
I’ll avoid unnecessary phrases and provide a concise description, project structure, configuration details, and usage instructions to ensure clarity. The aim is to keep code blocks minimal but comprehensive, making it easy for users to replicate the setup. Let’s get to it!Setting up package.json
I'm organizing the package.json for the minimal Next.js, Prisma, and Tailwind CSS starter template. For dependencies, it's safe to use "latest" versions for Next.js, React, and Prisma. However, to ensure compatibility, I’ll specify a stable release like "14.2.3" for Next.js and "18.2.0" for React.
I’ll include essential scripts for development, build, and Prisma commands. Also, for the quick start instructions, I’ll make sure to guide the user through the installation process clearly. Overall, I'm aiming for a straightforward and informative setup! Here’s a minimal Next.js + Prisma + Tailwind CSS starter you can drop into a new repo.
1. Project structure
next-prisma-tailwind-starter/
├─ prisma/
│ └─ schema.prisma
├─ src/
│ ├─ app/
│ │ ├─ api/
│ │ │ └─ users/
│ │ │ └─ route.ts
│ │ ├─ layout.tsx
│ │ └─ page.tsx
│ ├─ lib/
│ │ └─ prisma.ts
│ └─ styles/
│ └─ globals.css
├─ .env.example
├─ next.config.mjs
├─ package.json
├─ postcss.config.mjs
├─ tailwind.config.ts
└─ tsconfig.json
2. Config & tooling
package.json
{
"name": "next-prisma-tailwind-starter",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"prisma:generate": "prisma generate",
"prisma:push": "prisma db push",
"prisma:migrate": "prisma migrate dev",
"prisma:studio": "prisma studio"
},
"dependencies": {
"@prisma/client": "latest",
"next": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"autoprefixer": "latest",
"eslint": "latest",
"eslint-config-next": "latest",
"postcss": "latest",
"prisma": "latest",
"tailwindcss": "latest",
"typescript": "latest"
}
}
next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {
// Customize as needed
experimental: {}
};
export default nextConfig;
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": false,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "src/**/*", "*/**/*.ts", "*/**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
postcss.config.mjs
export default {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
tailwind.config.ts
import type { Config } from "tailwindcss";
const config: Config = {
content: [
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}"
],
theme: {
extend: {}
},
plugins: []
};
export default config;
3. Prisma setup
.env.example
# Copy this to `.env` and set your credentials
DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
(If you prefer SQLite, change the provider and URL in schema.prisma accordingly.)
prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql" // or "sqlite"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
name String?
createdAt DateTime @default(now())
}
src/lib/prisma.ts (singleton Prisma client)
import { PrismaClient } from "@prisma/client";
const globalForPrisma = globalThis as unknown as {
prisma?: PrismaClient;
};
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log: process.env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"]
});
if (process.env.NODE_ENV !== "production") {
globalForPrisma.prisma = prisma;
}
export default prisma;
4. Next.js (App Router) + Tailwind
src/styles/globals.css
@tailwind base;
@tailwind components;
@tailwind utilities;
/* Custom global styles */
html,
body {
height: 100%;
}
body {
@apply bg-gray-950 text-gray-100 antialiased;
}
src/app/layout.tsx
import type { Metadata } from "next";
import "../styles/globals.css";
export const metadata: Metadata = {
title: "Next + Prisma + Tailwind Starter",
description: "Minimal starter template"
};
export default function RootLayout(props: { children: React.ReactNode }) {
const { children } = props;
return (
<html lang="en">
<body className="min-h-screen">
<div className="mx-auto max-w-3xl px-4 py-8">{children}</div>
</body>
</html>
);
}
src/app/page.tsx (server component using Prisma)
import prisma from "@/lib/prisma";
export default async function HomePage() {
const users = await prisma.user.findMany({
orderBy: { createdAt: "desc" }
});
return (
<main className="space-y-6">
<header>
<h1 className="text-3xl font-bold">Next.js + Prisma + Tailwind</h1>
<p className="mt-2 text-sm text-gray-400">
This is a minimal starter template wired up end-to-end.
</p>
</header>
<section className="rounded-lg border border-gray-800 bg-gray-900 p-4">
<h2 className="mb-2 text-lg font-semibold">Users (via Prisma)</h2>
{users.length === 0 ? (
<p className="text-sm text-gray-500">
No users yet. Add some with <code className="font-mono">npx prisma studio</code>.
</p>
) : (
<ul className="space-y-1 text-sm">
{users.map((user) => (
<li key={user.id}>
<span className="font-medium">{user.name ?? "Unnamed user"}</span>
<span className="text-gray-400"> — {user.email}</span>
</li>
))}
</ul>
)}
</section>
</main>
);
}
src/app/api/users/route.ts (API route using Prisma)
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET() {
const users = await prisma.user.findMany({
orderBy: { createdAt: "desc" }
});
return NextResponse.json(users);
}
5. Getting started
From the project root:
# 1. Install dependencies
npm install
# or
yarn
# or
pnpm install
# 2. Set up environment
cp .env.example .env
# then edit .env and set DATABASE_URL
# 3. Generate Prisma client and create DB schema
npx prisma generate
npx prisma db push
# or via npm scripts:
# npm run prisma:generate
# npm run prisma:push
# 4. Run dev server
npm run dev
Then open http://localhost:3000:
- The homepage renders users from the database via Prisma.
GET /api/users returns JSON from Prisma.
If you want, I can adapt this to a specific database (SQLite/MySQL) or to Pages Router instead of App Router.