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.

Skills เพิ่มเติมจาก neondatabase

claimable-postgres
neondatabase
ฐานข้อมูล Postgres แบบทันทีสำหรับการพัฒนาในเครื่อง การสาธิต การสร้างต้นแบบ และสภาพแวดล้อมการทดสอบ ไม่ต้องมีบัญชี ฐานข้อมูลจะหมดอายุหลังจาก 72 ชั่วโมง เว้นแต่จะถูกอ้างสิทธิ์ไปยังบัญชี Neon
neon
neondatabase
ภาพรวมของแพลตฟอร์ม Neon สำหรับแอปและเอเจนต์ ครอบคลุม Postgres, Auth, Data API และบริการใหม่: Object Storage, Compute Functions และ AI Gateway ใช้เมื่อมีการกล่าวถึง "Neon" เพื่อดูภาพรวมการทำงานกับ Neon และวิธีการเริ่มต้น มิฉะนั้น ความสามารถเฉพาะตัวจะเป็นตัวกระตุ้น: "object storage" หรือ "S3-compatible storage", "serverless functions", "background jobs" หรือ "run code near my database", "AI gateway", "LLM proxy", "model routing" หรือ "call an LLM" →...
apidatabasedevelopment
plugin-manager
neondatabase
จัดการโครงสร้างปลั๊กอินและการกำหนดค่าสำหรับพื้นที่เก็บข้อมูลนี้ทั้งใน Cursor และ Claude Code ใช้เมื่อสร้าง อัปเดต หรือตรวจสอบโฟลเดอร์ปลั๊กอิน…
skill-creator
neondatabase
คู่มือสำหรับการสร้างสกิลที่มีประสิทธิภาพ สกิลนี้ควรใช้เมื่อผู้ใช้ต้องการสร้างสกิลใหม่ (หรืออัปเดตสกิลที่มีอยู่) ที่ขยายความสามารถของ Claude...
using-neon
neondatabase
คู่มือและแนวทางปฏิบัติที่ดีที่สุดสำหรับการทำงานกับ Neon Serverless Postgres ครอบคลุมการเริ่มต้นใช้งาน การพัฒนาท้องถิ่นกับ Neon การเลือกวิธีการเชื่อมต่อ Neon…
neon-js-react
neondatabase
ตั้งค่า Neon SDK แบบสมบูรณ์พร้อมการตรวจสอบสิทธิ์และการค้นหาฐานข้อมูลในแอป React (Vite, CRA) สร้างไคลเอนต์แบบมีชนิด สร้างชนิดข้อมูลฐานข้อมูล และกำหนดค่า…
postgres-best-practices
neondatabase
แนวทางปฏิบัติและข้อแนะนำที่ดีที่สุดสำหรับการทำงานกับ Postgres ครอบคลุมการออกแบบ schema, กลยุทธ์การสร้าง index, การปรับแต่ง query, การทำ migration, และข้อผิดพลาดที่พบบ่อย ใช้…
neon-postgres-egress-optimizer
neondatabase
แนะนำผู้ใช้ในการวินิจฉัยและแก้ไขรูปแบบการค้นหาข้อมูลฝั่งแอปพลิเคชันที่ทำให้เกิดการถ่ายโอนข้อมูลมากเกินไป (egress) จากฐานข้อมูล Postgres ของพวกเขา ค่าใช้จ่าย egress ที่สูงส่วนใหญ่มาจากแอปพลิเคชันที่ดึงข้อมูลมากกว่าที่ใช้งานจริง