Back to skills
SkillHub ClubShip Full StackBackendFrontend

neon-serverless

Configures Neon's PostgreSQL driver for serverless and edge environments like Vercel Edge Functions and AWS Lambda. Provides clear connection patterns, TypeScript examples, and specific guidance on import strategies. Includes practical templates and validation scripts.

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
81
Hot score
93
Updated
March 20, 2026
Overall rating
A8.3
Composite score
6.5
Best-practice grade
A92.0

Install command

npx @skill-hub/cli install neondatabase-ai-rules-neon-serverless
serverlessdatabasepostgresqledge-computingtypescript

Repository

neondatabase/ai-rules

Skill path: neon-plugin/skills/neon-serverless

Configures Neon's PostgreSQL driver for serverless and edge environments like Vercel Edge Functions and AWS Lambda. Provides clear connection patterns, TypeScript examples, and specific guidance on import strategies. Includes practical templates and validation scripts.

Open repository

Best for

Primary workflow: Ship Full Stack.

Technical facets: Backend, Frontend.

Target audience: Developers building serverless or edge applications with Next.js, Vercel Edge Functions, or AWS Lambda who need PostgreSQL database connectivity.

License: Unknown.

Original source

Catalog source: SkillHub Club.

Repository owner: neondatabase.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install neon-serverless into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/neondatabase/ai-rules before adding neon-serverless to shared team environments
  • Use neon-serverless for backend workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
name: neon-serverless
description: Configures Neon Serverless Driver for Next.js, Vercel Edge Functions, AWS Lambda, and other serverless environments. Installs @neondatabase/serverless, sets up environment variables, and creates working API route examples with TypeScript types. Use when users need to connect their application to Neon, fetch or query data from a Neon database, integrate Neon with Next.js or serverless frameworks, or set up database access in edge/serverless environments where traditional PostgreSQL clients don't work.
allowed-tools: ["bash"]
---

# Neon Serverless Skill

Configures the Neon Serverless Driver for optimal performance in serverless and edge computing environments.

## When to Use

- Setting up connections for edge functions (Vercel Edge, Cloudflare Workers)
- Configuring serverless APIs (AWS Lambda, Google Cloud Functions)
- Optimizing for low-latency database access
- Implementing connection pooling for high-throughput apps

**Not recommended for:** Complex multi-statement transactions (use WebSocket Pool), persistent servers (use native PostgreSQL drivers), or offline-first applications.

## Code Generation Rules

When generating TypeScript/JavaScript code:
- BEFORE generating import statements, check tsconfig.json for path aliases (compilerOptions.paths)
- If path aliases exist (e.g., "@/*": ["./src/*"]), use them (e.g., import { x } from '@/lib/utils')
- If NO path aliases exist or unsure, ALWAYS use relative imports (e.g., import { x } from '../../../lib/utils')
- Verify imports match the project's configuration
- Default to relative imports - they always work regardless of configuration

## Reference Documentation

**Primary Resource:** See `[neon-serverless.mdc](https://raw.githubusercontent.com/neondatabase-labs/ai-rules/main/neon-serverless.mdc)` in project root for comprehensive guidelines including:
- Installation and compatibility requirements
- HTTP vs WebSocket adapter selection
- Connection pooling strategies
- Query optimization patterns
- Error handling and troubleshooting

## Quick Setup

### Installation
```bash
npm install @neondatabase/serverless
```

### Connection Patterns

**HTTP Client** (recommended for edge/serverless):
```typescript
import { neon } from '@neondatabase/serverless';
const sql = neon(process.env.DATABASE_URL!);
const rows = await sql`SELECT * FROM users WHERE id = ${userId}`;
```

**WebSocket Pool** (for Node.js long-lived connections):
```typescript
import { Pool } from '@neondatabase/serverless';
const pool = new Pool({ connectionString: process.env.DATABASE_URL! });
const result = await pool.query('SELECT * FROM users WHERE id = $1', [userId]);
```

See `templates/` for complete examples:
- `templates/http-connection.ts` - HTTP client setup
- `templates/websocket-pool.ts` - WebSocket pool configuration

## Validation

Use `scripts/validate-connection.ts` to test your database connection before deployment.

## Related Skills

- **neon-auth** - Add authentication
- **neon-js** - Full SDK with auth + data API
- **neon-drizzle** - For ORM with serverless connections
- **neon-toolkit** - For ephemeral database testing

---

**Want best practices in your project?** Run `neon-plugin:add-neon-docs` with parameter `SKILL_NAME="neon-serverless"` to add reference links.
neon-serverless | SkillHub