This repository provides a boilerplate to quickly set up a Next.js application with Prisma Postgres and Prisma ORM, and deploy it to Netlify. It includes an easy setup process and example routes that demonstrate basic CRUD operations.
For the deployment on Netlify, you can use the Prisma Postgres extension for Netlify.
Follow these steps to quickly set up the project and start using Prisma ORM with Next.js.
Create a Prisma Postgres database instance using Prisma Data Platform:
- Navigate to Prisma Data Platform.
- Click New project to create a new project.
- Enter a name for your project in the Name field.
- Inside the Prisma Postgres® section, click Get started.
- Choose a region close to your location from the Region dropdown.
- Click Create project to set up your database. This redirects you to the database setup page.
- In the Set up database access section, copy the
DATABASE_URL
. You will use this in the next steps.
You now need to configure your database connection via an environment variable.
First, create an .env
file:
touch .env
Then update the .env
file by replacing the existing DATABASE_URL
value with the one you previously copied. It will look similar to this:
DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=PRISMA_POSTGRES_API_KEY"
Run the following commands to set up your database and Prisma schema:
npx prisma migrate dev --name init
Expand for yarn
, pnpm
or bun
# Using yarn
yarn prisma migrate dev --name init
# Using pnpm
pnpm prisma migrate dev --name init
# Using bun
bun prisma migrate dev --name init
Add initial data to your database:
npx prisma db seed
Expand for yarn
, pnpm
or bun
# Using yarn
yarn prisma db seed
# Using pnpm
pnpm prisma db seed
# Using bun
bun prisma db seed
Start the development server:
npm run dev
Expand for yarn
, pnpm
or bun
# Using yarn
yarn dev
# Using pnpm
pnpm run dev
# Using bun
bun run dev
Once the server is running, visit http://localhost:3000
to start using the app.
For the deployment on Netlify, you can use the Prisma Postgres extension for Netlify.