Skip to content

aitchiss/plain-nextjs-netlify-demo

Repository files navigation

Next.js & Prisma Postgres starter

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.

Getting started

Follow these steps to quickly set up the project and start using Prisma ORM with Next.js.

1. Create a Prisma Postgres instance

Create a Prisma Postgres database instance using Prisma Data Platform:

  1. Navigate to Prisma Data Platform.
  2. Click New project to create a new project.
  3. Enter a name for your project in the Name field.
  4. Inside the Prisma Postgres® section, click Get started.
  5. Choose a region close to your location from the Region dropdown.
  6. Click Create project to set up your database. This redirects you to the database setup page.
  7. In the Set up database access section, copy the DATABASE_URL. You will use this in the next steps.

2. Setup your .env file

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"

3. Migrate the database

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

4. Seed the database

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

5. Run the app

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.

Deploy to Netlify

For the deployment on Netlify, you can use the Prisma Postgres extension for Netlify.

Deploy to Netlify

Next steps

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published