Skip to content

Ross249/nextjs-with-postgres-neon

Repository files navigation

Next.js + Postgres and Neon

This example shows how you can use a Postgres database to support your Next.js application and style by Tailwind CSS.

Configuration

Step 1. Get the connection string of your Postgres

In neon, the string like this:

	postgres://<role>:<password>@<hostname>/<database>

Step 2. Set up environment variables

Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):

cp .env.local.example .env.local

Then set each variable on .env.local:

  • DATABASE_URL should be the Postgres connection string you got from step 1.

Step 3. Run Next.js in development mode

npm install
npm run dev

# or

yarn install
yarn dev

Your app should be up and running on http://localhost:3000! If it doesn't work, post on GitHub discussions.

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.