Skip to content

app-generator/docs-nextjs-drizzle-orm

Repository files navigation

This quick guide demonstrates the use of Drizzle with server components in Next.js. We breeze past the initial steps for spinning up a local PostgreSQL server and starting a Next.js app.

👉 How to use Drizzle with server components in Next.js. - Complete Documentation


Spin Up a Local Postgres Instance

First, install PostgreSQL locally and start a running database instance named drizzle_nextjs using either psql or pgAdmin. If you need a refresher, please refer to this YouTube tutorial.

PostgreSQL Credentials

Have the credentials of your Postgres instance ready, in a .env file stored at the root. It should follow this format:

DB_HOST=localhost
DB_PORT_NO=5432
DB_USERNAME=postgres
DB_PASSWORD="YOUR_PASSWORD"
DB_NAME=drizzle_nextjs
DB_URL=postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT/${DB_NAME}

Application Setup

  1. Clone this repo from here.
  2. cd in and Install dependencies:
npm i
  1. Generate Drizzle migration files:
npm run db:generate
  1. Run database migrations:
npm run db:migrate
  1. Seed database:
npm run db:seed
  1. Run the Next.js server:
npm run dev

Visit http://localhost:3000/. The app should be running.


Nextjs With Drizzle ORM - Free sample provided by App Generator

About

RSC and Drizzle ORM in Next.js | App-Generator Docs

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •