neon-serverless

作成者: neondatabase

Neon Serverless DriverをNext.js、Vercel Edge Functions、AWS Lambda、その他のサーバーレス環境向けに設定します。@neondatabase/serverlessをインストールし、セットアップします…

npx skills add https://github.com/neondatabase/ai-rules --skill neon-serverless

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

npm install @neondatabase/serverless

Connection Patterns

HTTP Client (recommended for edge/serverless):

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):

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.

neondatabaseのその他のスキル

claimable-postgres
neondatabase
ローカル開発、デモ、プロトタイピング、テスト環境向けの即時Postgresデータベース。アカウント不要。Neonアカウントにクレームしない限り、データベースは72時間後に期限切れとなります。
neon
neondatabase
Neonプラットフォームの概要。アプリやエージェント向けに、Postgres、Auth、Data API、および新サービス(オブジェクトストレージ、コンピュート関数、AIゲートウェイ)を網羅。"Neon"が言及された際に、Neonの操作方法や開始方法の概要として使用。それ以外の場合、個別機能がトリガーとなる:「オブジェクトストレージ」または「S3互換ストレージ」、「サーバーレス関数」、「バックグラウンドジョブ」または「データベース近くでコードを実行」、「AIゲートウェイ」、「LLMプロキシ」、「モデルルーティング」または「LLMを呼び出す」→...
apidatabasedevelopment
plugin-manager
neondatabase
このリポジトリのプラグイン構造と設定を、CursorとClaude Codeの両方で管理します。プラグインフォルダの作成、更新、レビュー時に使用してください…
skill-creator
neondatabase
効果的なスキルを作成するためのガイド。このスキルは、ユーザーがClaudeの機能を拡張する新しいスキルを作成(または既存のスキルを更新)したい場合に使用されるべきです。
using-neon
neondatabase
Neon Serverless Postgresを扱うためのガイドとベストプラクティス。はじめ方、Neonを使ったローカル開発、接続方法の選択、Neon…
neon-js-react
neondatabase
Reactアプリ(Vite、CRA)で認証とデータベースクエリを備えた完全なNeon SDKをセットアップします。型付きクライアントを作成し、データベース型を生成し、設定を行います…
postgres-best-practices
neondatabase
Postgresを扱う際のベストプラクティスとガイドライン。スキーマ設計、インデックス戦略、クエリ最適化、マイグレーション、よくある落とし穴をカバー。使用…
neon-postgres-egress-optimizer
neondatabase
ユーザーがPostgresデータベースから過剰なデータ転送(エグレス)を引き起こすアプリケーション側のクエリパターンを診断し修正する手順を案内します。高いエグレス料金のほとんどは、アプリケーションが必要以上