Skip to content
Back to Templates

Vercel with Neon Postgres

A minimal template for building full-stack React applications using Next.js, Vercel, and Neon.

Contentful thumbnail for Vercel with Neon Postgres

Neon Postgres Vercel Marketplace Template

A minimal template for building full-stack React applications using Next.js, Vercel, and Neon.

Getting Started

Click the "Deploy" button to clone this repo, create a new Vercel project, setup the Neon integration, and provision a new Neon database:

Once the process is complete, you can clone the newly created GitHub repository and start making changes locally.

Demo

View live demo: vercel-marketplace-neon.vercel.app

Local Setup

Installation

Install the dependencies:

npm install

You can use the package manager of your choice. For example, Vercel also supports bun install out of the box.

Development

Create a .env file in the project root
cp .env.example .env
Get your database URL

Run vercel env pull to fetch the environment variables from your Vercel project.

Alternatively, obtain the database connection string from the Connection Details widget on the Neon Dashboard and add it to the .env file:

DATABASE_URL=<postgres://user:pass@host/db>
Start the development server
npm run dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

Neon MCP Server & Agent Skill

This project includes the Neon MCP server and neon-postgres agent skill for AI-assisted development with Neon Postgres. Both are configured for Cursor, Claude Code and VS Code.

Shadcn/ui

This project uses shadcn/ui for building accessible and customizable UI components.

Configuration

Shadcn/ui is configured in components.json. The project uses:

  • Style: New York
  • Base Color: Neutral
  • Icon Library: Lucide React
  • CSS Variables: Enabled for theming

Adding Components

To add new shadcn/ui components:

npx shadcn@latest add [component-name]

For example:

npx shadcn@latest add card
npx shadcn@latest add dialog

Theme Support

The project includes a theme provider and selector:

  • Theme Provider: src/components/themes/provider.tsx
  • Theme Selector: src/components/themes/selector.tsx

Themes are managed using next-themes and support light, dark, and system preferences.

Existing Components

  • Button - src/components/ui/button.tsx
  • DropdownMenu - src/components/ui/dropdown-menu.tsx

Learn More

Drizzle ORM

This project uses Drizzle ORM for type-safe database operations with PostgreSQL.

Configuration

Drizzle is configured in drizzle.config.ts. The database client is set up in src/lib/db/client.ts.

Schema

Database schemas are defined in src/lib/db/schema.ts. Currently includes an example users table that can be customized or removed based on your needs.

Database Scripts

  • npm run db:generate - Generate migration files from your schema
  • npm run db:migrate - Apply migrations to your database
  • npm run db:studio - Open Drizzle Studio (visual database browser)

Usage Example

import { db } from "@/lib/db/client";
import { users } from "@/lib/db/schema";
import { eq } from "drizzle-orm";
// Select all users
const allUsers = await db.select().from(users);
// Insert a user
await db.insert(users).values({
id: "123",
name: "John Doe",
email: "john@example.com",
});
// Update a user
await db.update(users)
.set({ name: "Jane Doe" })
.where(eq(users.id, "123"));

Running Migrations

  1. Update your schema in src/lib/db/schema.ts
  2. Generate migrations: npm run db:generate
  3. Review the generated SQL in the drizzle/ folder
  4. Apply migrations: npm run db:migrate

Learn More

Learn More

To learn more about Neon, check out the Neon documentation:

To learn more about Next.js, take a look at the following resources:

Deploy on Vercel

Commit and push your code changes to your GitHub repository to automatically trigger a new deployment.