drizzle-neon

Integrates Drizzle ORM and Neon PostgreSQL into Scaffold-ETH 2 dApps.

2.0k|1.4k|Updated Sep 19, 2022
One-click install
npx skills add https://github.com/scaffold-eth/scaffold-eth-2 --skill drizzle-neon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drizzle-neon
Source: https://github.com/scaffold-eth/scaffold-eth-2/tree/main/.agents/skills/drizzle-neon
Command: npx skills add https://github.com/scaffold-eth/scaffold-eth-2 --skill drizzle-neon

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires drizzle-orm, @neondatabase/serverless, pg, drizzle-kit, drizzle-seed, dotenv, tsx.

What problem does it solve?

Adding persistent off-chain storage to a Scaffold-ETH 2 dApp requires wiring up an ORM, database drivers, migrations, and environment configuration by hand. This Skill automates that integration, giving your dApp a type-safe PostgreSQL backend that works locally via Docker and in production via Neon serverless.

Core Features & Use Cases

  • Tri-Driver Database Client: Auto-detects the environment and selects the right driver (Neon serverless WebSocket, Neon HTTP, or standard node-postgres) based on the connection string and runtime.
  • Repository Pattern & Schema Setup: Generates typed CRUD repositories, Drizzle schema definitions, and drizzle-kit configuration with consistent snake_case casing.
  • Full Workflow Tooling: Includes Docker Compose for local Postgres, seed/wipe scripts with production safety guards, and migration commands for production deployment.
  • Use Case: You are building a dApp that needs to store user profiles off-chain. Use this Skill to scaffold the database layer, then query it directly from Next.js server components or expose mutations through API routes with React Query.

Quick Start

Add a PostgreSQL database with Drizzle ORM and Neon to my Scaffold-ETH 2 project so I can store off-chain user data.

Frequently Asked Questions about drizzle-neon

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a PostgreSQL database to a Scaffold-ETH 2 project?

Add Drizzle ORM and Neon dependencies to the NextJS package, create a schema in services/database/config/schema.ts, and configure a database client that reads POSTGRES_URL. Run docker compose up for local Postgres, then yarn drizzle-kit push to apply the schema.

How do I use Drizzle ORM with Neon serverless PostgreSQL?

Set POSTGRES_URL to your Neon connection string containing neondb. The client auto-selects drizzle-orm/neon-serverless in the Next.js runtime and drizzle-orm/neon-http for scripts needing batch operations, while local development uses node-postgres.

Can I query the database directly from Next.js server components?

Yes, server components can import repository functions and call the database directly without API routes. For client-side mutations, create API routes that call the repositories and use @tanstack/react-query's useQuery and useMutation on the client.

Why do Drizzle queries fail or return wrong data after setup?

The most common cause is mismatched casing configuration. The casing: snake_case option must be set in both drizzle.config.ts and every drizzle() client initialization, otherwise queries reference wrong column names silently.

When should I use drizzle-kit push versus generate and migrate?

Use drizzle-kit push during active development for fast schema iteration without migration files. Switch to drizzle-kit generate and migrate once the schema is stable, and never use push in production environments.