apps/docs/content/docs/guides/making-guides.mdx
This guide shows you how to write guides for Prisma ORM documentation. It covers the required structure, formatting, and style conventions to ensure consistency across all guides. You'll learn about frontmatter requirements, section organization, and writing style.
Before writing a guide, make sure you have:
Every guide must include the following frontmatter at the top of the file:
---
title: '[Descriptive title]'
description: '[One-sentence summary of what the guide covers]'
---
title: A clear, descriptive title (e.g., "Next.js", "Multiple databases", "GitHub Actions")description: A one-sentence summary that describes what you'll learn or accomplishimage: A unique header image for social media sharing (coordinate with the design team)All frontmatter fields should use sentence case.
Introduction (H2: ##)
Prerequisites (H2: ##)
Main content sections (H2: ##)
Next steps (H2: ##)
title=// [!code ++] to highlight added lines// [!code --] to highlight removed lines```npm for package manager commands (auto-converts to pnpm/yarn/bun)```bash for shell commands```text for plain text files like .env```typescript, ```prisma, ```json for respective languagesExample with file path:
import { PrismaClient } from "../generated/prisma";
import { PrismaPg } from "@prisma/adapter-pg";
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});
const prisma = new PrismaClient({
adapter,
});
export default prisma;
Example showing changes:
import "dotenv/config"; // [!code ++]
import { defineConfig, env } from "prisma/config";
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
},
datasource: {
url: env("DATABASE_URL"),
},
});
`schema.prisma``prisma/``PrismaClient````npm blocks (see Package manager commands):::info
Context or background information
:::
:::note
Important details to remember
:::
:::warning
Critical information or gotchas
:::
:::tip
Helpful suggestions or best practices
:::
[Database drivers](/orm/core-concepts/supported-databases/database-drivers))| Category | Directory | Description | Examples |
|---|---|---|---|
| Framework | guides/frameworks/ | Integrate Prisma with frameworks | Next.js, NestJS, SvelteKit |
| Deployment | guides/deployment/ | Deploy apps and set up monorepos | Turborepo, Cloudflare Workers |
| Integration | guides/integrations/ | Use Prisma with platforms and tools | GitHub Actions, Supabase |
| Database | guides/database/ | Database patterns and migrations | Multiple databases, Data migration |
| Authentication | guides/authentication/ | Authentication patterns with Prisma | Auth.js + Next.js, Better Auth + Next.js, Clerk + Next.js |
| Prisma Postgres | guides/postgres/ | Prisma Postgres features | Vercel, Netlify, Viewing data |
| Migration | guides/switch-to-prisma-orm/ | Switch from other ORMs | From Mongoose, From Drizzle |
Use ```npm code blocks for package manager commands. These automatically convert to other package managers (pnpm, yarn, bun) in the UI:
npm install prisma --save-dev
Show .env file examples using ```text blocks:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
Include an info admonition when commands or code are PostgreSQL-specific:
:::info
If you are using a different database provider (MySQL, SQL Server, SQLite), install the corresponding driver adapter package instead of `@prisma/adapter-pg`. For more information, see [Database drivers](/orm/core-concepts/supported-databases/database-drivers).
:::
Show the standard pattern for creating a Prisma Client with database adapters:
import { PrismaClient } from "../generated/prisma";
import { PrismaPg } from "@prisma/adapter-pg";
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});
const prisma = new PrismaClient({
adapter,
});
export default prisma;
Include a warning about connection pooling:
:::warning
We recommend using a connection pooler (like [Prisma Accelerate](https://www.prisma.io/accelerate)) to manage database connections efficiently.
:::
Keep it focused
Show don't tell
Consider the context
Maintain consistency
Think about maintenance
Use this template as a starting point for new guides. The template includes common sections and patterns used across Prisma guides.
Copy this template for a new guide:
---
title: '[Your guide title]'
description: '[One-sentence summary of what you'll learn]'
image: '/img/guides/[guide-name]-cover.png'
---
## Introduction
[Brief overview of what this guide covers and what you'll accomplish. Include a link to an example repository if available.]
## Prerequisites
- [Node.js 20+](https://nodejs.org)
- [Any other prerequisites]
## 1. Set up your project
[Instructions for creating or setting up the project]
```npm
# Example command
npx create-next-app@latest my-app
cd my-app
```
## 2. Install and Configure Prisma
### 2.1. Install dependencies
To get started with Prisma, you'll need to install a few dependencies:
```npm
npm install prisma tsx @types/pg --save-dev
```
```npm
npm install @prisma/client @prisma/adapter-pg dotenv pg
```
:::info
If you are using a different database provider (MySQL, SQL Server, SQLite), install the corresponding driver adapter package instead of `@prisma/adapter-pg`. For more information, see [Database drivers](/orm/core-concepts/supported-databases/database-drivers).
:::
Once installed, initialize Prisma in your project:
```npm
npx prisma init --db --output ../generated/prisma
```
:::info
You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database.
:::
This will create:
- A `prisma` directory with a `schema.prisma` file
- A Prisma Postgres database
- A `.env` file containing the `DATABASE_URL`
- A `prisma.config.ts` file for configuration
### 2.2. Define your Prisma Schema
In the `prisma/schema.prisma` file, add your models:
```prisma title="prisma/schema.prisma"
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
}
model User { // [!code ++]
id Int @id @default(autoincrement()) // [!code ++]
email String @unique // [!code ++]
name String? // [!code ++]
posts Post[] // [!code ++]
} // [!code ++]
model Post { // [!code ++]
id Int @id @default(autoincrement()) // [!code ++]
title String // [!code ++]
content String? // [!code ++]
published Boolean @default(false) // [!code ++]
authorId Int // [!code ++]
author User @relation(fields: [authorId], references: [id]) // [!code ++]
} // [!code ++]
```
### 2.3. Run migrations and generate Prisma Client
Create the database tables:
```npm
npx prisma migrate dev --name init
```
Then generate Prisma Client:
```npm
npx prisma generate
```
## 3. [Integration-specific steps]
[Add framework or platform-specific integration steps here]
## Next steps
Now that you've completed this guide, you can:
- [Suggestion 1]
- [Suggestion 2]
- [Related guide 1](/path/to/guide)
- [Related guide 2](/path/to/guide)
For more information:
- [Prisma documentation](/orm)
- [Related documentation]
Guides are organized by category in subdirectories. To add a guide to the navigation, you need to update the appropriate meta.json file.
The main guide categories are listed in meta.json:
{
"title": "Guides",
"root": true,
"icon": "NotebookTabs",
"pages": [
"index",
"frameworks",
"deployment",
"authentication",
"integrations",
"postgres",
"database",
"switch-to-prisma-orm",
"upgrade-prisma-orm"
]
}
To add a guide to a category (e.g., frameworks), edit the category's meta.json file:
{
"title": "Frameworks",
"defaultOpen": true,
"pages": [
"nextjs",
"astro",
"nuxt",
"your-new-guide" // [!code ++]
]
}
The page name should match your .mdx filename without the extension. For example, if your file is your-new-guide.mdx, add "your-new-guide" to the pages array.
After reading this guide, you can: