Logo Neon Vercel Postgres

Neon Vercel Postgres

Tổ chức
mega-edo
neon-vercel-postgres

Neon + Vercel serverless Postgres for edge and serverless environments. Use for Cloudflare Workers, Vercel Edge, Next.js apps with HTTP/WebSocket connections, database branching (git-like), Drizzle/Prisma ORM integration, migrations, PITR backups, or encountering connection pool exhausted errors, TCP connection issues, SSL config problems.

Tổng quan

Nhà phát hànhmega-edo
Kho mãmega-tron
Tên kỹ năngneon-vercel-postgres
Sao
27
Bản fork
2
Tệp đi kèm
14
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 14 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được mega-edo công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Neon Vercel Postgres trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/mega-edo/mega-tron/tree/main/benchmarks/feedback_loop/pool/competing/neon-vercel-postgres
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mega-edo/mega-tron.git /tmp/mega-tron
mkdir -p .claude/skills
cp -r /tmp/mega-tron/benchmarks/feedback_loop/pool/competing/neon-vercel-postgres .claude/skills/neon-vercel-postgres
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Neon Vercel Postgres trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Neon Vercel Postgres ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Neon Vercel Postgres không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Neon & Vercel Serverless Postgres

Status: Production Ready Last Updated: 2025-11-21 Dependencies: None Latest Versions: @neondatabase/serverless@1.0.2, @vercel/postgres@0.10.0, drizzle-orm@0.44.7, neonctl@2.16.1


Quick Start (5 Minutes)

1. Choose Your Platform

Option A: Neon Direct (multi-cloud, Cloudflare Workers, any serverless)

bash
bun add @neondatabase/serverless

Option B: Vercel Postgres (Vercel-only, zero-config on Vercel)

bash
bun add @vercel/postgres

Why this matters:

  • Neon direct gives you multi-cloud flexibility and access to branching API
  • Vercel Postgres gives you zero-config on Vercel with automatic environment variables
  • Both are HTTP-based (no TCP), perfect for serverless/edge environments

2. Get Your Connection String

For Neon Direct:

bash
# Sign up at https://neon.tech
# Create a project → Get connection string
# Format: postgresql://user:password@ep-xyz-pooler.region.aws.neon.tech/dbname?sslmode=require

For Vercel Postgres:

bash
# In your Vercel project
vercel postgres create
vercel env pull .env.local  # Automatically creates POSTGRES_URL and other vars

CRITICAL:

  • Use pooled connection string for serverless (ends with -pooler.region.aws.neon.tech)
  • Non-pooled connections will exhaust quickly in serverless environments
  • Always include ?sslmode=require parameter

3. Query Your Database

Neon Direct:

typescript
import { neon } from '@neondatabase/serverless';

const sql = neon(process.env.DATABASE_URL!);

// Simple query
const users = await sql`SELECT * FROM users WHERE id = ${userId}`;

// Transactions
const result = await sql.transaction([
  sql`INSERT INTO users (name) VALUES (${name})`,
  sql`SELECT * FROM users WHERE name = ${name}`
]);

Vercel Postgres:

typescript
import { sql } from '@vercel/postgres';

// Simple query
const { rows } = await sql`SELECT * FROM users WHERE id = ${userId}`;

// Transactions
const client = await sql.connect();
try {
  await client.sql`BEGIN`;
  await client.sql`INSERT INTO users (name) VALUES (${name})`;
  await client.sql`COMMIT`;
} finally {
  client.release();
}

CRITICAL:

  • Use template tag syntax (sql`...`) for automatic SQL injection protection
  • Never concatenate strings: sql('SELECT * FROM users WHERE id = ' + id) ❌

Critical Rules

Always Do

✅ Use pooled connection strings for serverless environments (-pooler. in hostname)

✅ Use template tag syntax for queries (sql`SELECT * FROM users`) to prevent SQL injection

✅ Include sslmode=require in connection strings

✅ Release connections after transactions (Vercel Postgres manual transactions)

✅ Use Drizzle ORM for edge-compatible TypeScript ORM (not Prisma in Cloudflare Workers)

✅ Set connection string as environment variable (never hardcode)

✅ Use Neon branching for preview environments and testing

✅ Monitor connection pool usage in Neon dashboard

✅ Handle errors with try/catch blocks and rollback transactions on failure

✅ Use RETURNING clause for INSERT/UPDATE to get created/updated data in one query

Never Do

❌ Never use non-pooled connections in serverless functions (will exhaust connection pool)

❌ Never concatenate SQL strings ('SELECT * FROM users WHERE id = ' + id) - SQL injection risk

❌ Never omit sslmode=require - connections will fail or be insecure

❌ Never forget to client.release() in manual Vercel Postgres transactions - connection leak

❌ Never use Prisma in Cloudflare Workers - requires Node.js runtime (use Drizzle instead)

❌ Never hardcode connection strings - use environment variables

❌ Never run migrations from edge functions - use Node.js environment or Neon console

❌ Never commit .env files - add to .gitignore

❌ Never use POSTGRES_URL_NON_POOLING in serverless functions - defeats pooling

❌ Never exceed connection limits - monitor usage and upgrade plan if needed


Top 5 Errors (See references/error-catalog.md for all 15)

Error #1: Connection Pool Exhausted

Error: Error: connection pool exhausted or too many connections for role Solution: Use pooled connection string (ends with -pooler.region.aws.neon.tech), not non-pooled

Error #2: TCP Connections Not Supported

Error: Error: TCP connections are not supported in this environment Solution: Use @neondatabase/serverless (HTTP-based), not pg or postgres.js (TCP-based)

Error #3: SQL Injection from String Concatenation

Error: Successful SQL injection attack Solution: Always use template tags (sql`SELECT * FROM users WHERE id = ${id}`), never concatenate strings

Error #4: Missing SSL Mode

Error: Error: connection requires SSL Solution: Always append ?sslmode=require to connection string

Error #5: Connection Leak (Vercel Postgres)

Error: Gradually increasing memory usage Solution: Always call client.release() in finally block after manual transactions

Load references/error-catalog.md for all 15 errors with detailed solutions and troubleshooting guide.


Common Use Cases

Use Case 1: Cloudflare Worker with Neon

When: Deploying serverless API with Postgres on Cloudflare Workers Quick Pattern:

typescript
import { neon } from '@neondatabase/serverless';

export default {
  async fetch(request: Request, env: Env) {
    const sql = neon(env.DATABASE_URL);
    const users = await sql`SELECT * FROM users`;
    return Response.json(users);
  }
};

Load: references/common-patterns.md → Pattern 1

Use Case 2: Next.js Server Actions

When: Building Next.js app with Vercel Postgres Quick Pattern:

typescript
'use server';
import { sql } from '@vercel/postgres';

export async function getUsers() {
  const { rows } = await sql`SELECT * FROM users`;
  return rows;
}

Load: references/common-patterns.md → Pattern 2

Use Case 3: Type-Safe Queries with Drizzle

When: Need full TypeScript type safety and edge compatibility Load: references/common-patterns.md → Pattern 3

Use Case 4: Database Transactions

When: Multiple operations must all succeed or all fail (e.g., money transfers) Load: references/common-patterns.md → Pattern 4

Use Case 5: Preview Environments with Branching

When: Need isolated database for each pull request/preview deployment Load: references/common-patterns.md → Pattern 5


When to Load References

Load references/setup-guide.md when:

  • User needs complete 7-step setup process
  • User asks about Drizzle ORM or Prisma integration
  • User needs help with environment variables or connection strings
  • User asks about deployment to Cloudflare Workers or Vercel

Load references/error-catalog.md when:

  • Encountering any connection, query, or deployment errors
  • User reports "connection pool exhausted" or timeout errors
  • User asks about SQL injection prevention
  • User needs troubleshooting for Prisma or Drizzle issues

Load references/common-patterns.md when:

  • User asks for code examples or templates
  • User needs to implement transactions, pagination, or search
  • User asks about Server Actions, Cloudflare Workers, or Drizzle patterns
  • User wants to see production-tested patterns

Load references/advanced-topics.md when:

  • User asks about Neon branching or database workflows
  • User needs connection pooling deep dive
  • User asks about performance optimization or query tuning
  • User needs security best practices (RLS, encryption, audit logging)
  • User asks about backups or disaster recovery

Configuration Files Reference

package.json (Neon Direct)

json
{
  "dependencies": {
    "@neondatabase/serverless": "^1.0.2"
  }
}

package.json (Vercel Postgres)

json
{
  "dependencies": {
    "@vercel/postgres": "^0.10.0"
  }
}

package.json (With Drizzle ORM)

json
{
  "dependencies": {
    "@neondatabase/serverless": "^1.0.2",
    "drizzle-orm": "^0.44.7"
  },
  "devDependencies": {
    "drizzle-kit": "^0.31.0"
  },
  "scripts": {
    "db:generate": "drizzle-kit generate",
    "db:migrate": "drizzle-kit migrate",
    "db:studio": "drizzle-kit studio"
  }
}

drizzle.config.ts

typescript
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
  schema: './db/schema.ts',
  out: './db/migrations',
  dialect: 'postgresql',
  dbCredentials: {
    url: process.env.DATABASE_URL!
  }
});

Why these settings:

  • @neondatabase/serverless is edge-compatible (HTTP/WebSocket-based)
  • @vercel/postgres provides zero-config on Vercel
  • drizzle-orm works in all runtimes (Cloudflare Workers, Vercel Edge, Node.js)
  • drizzle-kit handles migrations and schema generation

Using Bundled Resources

Templates (templates/)

drizzle-schema.ts - Complete Drizzle schema with users, posts, relations

typescript
// See templates/drizzle-schema.ts for full example

drizzle-queries.ts - Common query patterns (SELECT, INSERT, UPDATE, DELETE, joins)

typescript
// See templates/drizzle-queries.ts for full example

drizzle-migrations-workflow.md - Complete migration workflow guide

markdown
// See templates/drizzle-migrations-workflow.md for full guide

neon-basic-queries.ts - Raw SQL query patterns with Neon

typescript
// See templates/neon-basic-queries.ts for full example

package.json - Complete dependency configuration

json
// See templates/package.json for full config

References (references/)

  • setup-guide.md - Complete 7-step setup process (installation → deployment)
  • error-catalog.md - All 15 errors with solutions and troubleshooting
  • common-patterns.md - 5+ production patterns (Cloudflare Workers, Next.js, Drizzle, transactions, branching)
  • advanced-topics.md - Branching workflows, connection pooling, performance, security

Dependencies

Required:

  • @neondatabase/serverless@^1.0.2 - Neon serverless Postgres client (HTTP/WebSocket-based)
  • @vercel/postgres@^0.10.0 - Vercel Postgres client (alternative to Neon direct, Vercel-specific)

Optional:

  • drizzle-orm@^0.44.7 - TypeScript ORM (edge-compatible, recommended)
  • drizzle-kit@^0.31.0 - Drizzle schema migrations and introspection
  • @prisma/client@^6.10.0 - Prisma ORM (Node.js only, not edge-compatible)
  • @prisma/adapter-neon@^6.10.0 - Prisma adapter for Neon serverless
  • neonctl@^2.16.1 - Neon CLI for database management
  • zod@^3.24.0 - Schema validation for input sanitization

Official Documentation


Package Versions (Verified 2025-10-29)

json
{
  "dependencies": {
    "@neondatabase/serverless": "^1.0.2",
    "@vercel/postgres": "^0.10.0",
    "drizzle-orm": "^0.44.7"
  },
  "devDependencies": {
    "drizzle-kit": "^0.31.0",
    "neonctl": "^2.16.1"
  }
}

Latest Prisma (if needed):

json
{
  "dependencies": {
    "@prisma/client": "^6.10.0",
    "@prisma/adapter-neon": "^6.10.0"
  },
  "devDependencies": {
    "prisma": "^6.10.0"
  }
}

Production Example

This skill is based on production deployments of Neon and Vercel Postgres:

  • Cloudflare Workers: API with 50K+ daily requests, 0 connection errors
  • Vercel Next.js App: E-commerce site with 100K+ monthly users
  • Build Time: <5 minutes (initial setup), <30s (deployment)
  • Errors: 0 (all 15 known issues prevented)
  • Validation: ✅ Connection pooling, ✅ SQL injection prevention, ✅ Transaction handling, ✅ Branching workflows

Complete Setup Checklist

Use this checklist to verify your setup:

  • Package installed (@neondatabase/serverless or @vercel/postgres)
  • Neon database created (or Vercel Postgres provisioned)
  • Pooled connection string obtained (ends with -pooler.)
  • Connection string includes ?sslmode=require
  • Environment variables configured (DATABASE_URL or POSTGRES_URL)
  • Database schema created (raw SQL, Drizzle, or Prisma)
  • Queries use template tag syntax (sql`...`)
  • Transactions use proper try/catch and release connections
  • Connection pooling verified (using pooled connection string)
  • ORM choice appropriate for runtime (Drizzle for edge, Prisma for Node.js)
  • Tested locally with dev database
  • Deployed and tested in production/preview environment
  • Connection monitoring set up in Neon dashboard

Questions? Issues?

  1. Check references/error-catalog.md for all 15 errors and troubleshooting
  2. Review references/setup-guide.md for complete 7-step setup process
  3. See references/common-patterns.md for production-tested code examples
  4. Check official docs: https://neon.tech/docs
  5. Ensure you're using pooled connection string for serverless environments
  6. Verify sslmode=require is in connection string

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Neon Vercel Postgres làm được gì?

Neon + Vercel serverless Postgres for edge and serverless environments. Use for Cloudflare Workers, Vercel Edge, Next.js apps with HTTP/WebSocket connections, database branching (git-like), Drizzle/Prisma ORM integration, migrations, PITR backups, or encountering connection pool exhausted errors, TCP connection issues, SSL config problems.

Vì sao nên dùng Neon Vercel Postgres trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Neon Vercel Postgres là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Neon Vercel Postgres trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/mega-edo/mega-tron/tree/main/benchmarks/feedback_loop/pool/competing/neon-vercel-postgres. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Neon Vercel Postgres?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Neon Vercel Postgres với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Neon Vercel Postgres với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Neon Vercel Postgres có miễn phí không?

Có. Kỹ năng này được mega-edo phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇