Neon Serverless Postgres
Neon is a serverless Postgres platform that separates compute and storage to offer autoscaling, branching, instant restore, and scale-to-zero. It's fully compatible with Postgres and works with any language, framework, or ORM that supports Postgres.
Neon Documentation
The Neon documentation is the source of truth for all Neon-related information. Always verify claims against the official docs before responding. Neon features and APIs evolve, so prefer fetching current docs over relying on training data.
Fetching Docs as Markdown
Any Neon doc page can be fetched as markdown in two ways:
- 1. Append
.md to the URL (simplest): https://neon.com/docs/introduction/branching.md - Request
text/markdown on the standard URL: INLINECODE2
Both return the same markdown content. Use whichever method your tools support.
Finding the Right Page
The docs index lists every available page with its URL and a short description:
CODEBLOCK0
Common doc URLs are organized in the topic links below. If you need a page not listed here, search the docs index: https://neon.com/docs/llms.txt — don't guess URLs.
What Is Neon
Use this for architecture explanations and terminology (organizations, projects, branches, endpoints) before giving implementation advice.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/what-is-neon.md
Getting Started
Use this for first-time setup: org/project selection, connection strings, driver installation, optional auth, and initial schema setup.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/getting-started.md
Connection Methods & Drivers
Use this when you need to pick the correct transport and driver based on runtime constraints (TCP, HTTP, WebSocket, edge, serverless, long-running).
Link: https://neon.com/docs/ai/skills/neon-postgres/references/connection-methods.md
Serverless Driver
Use this for @neondatabase/serverless patterns, including HTTP queries, WebSocket transactions, and runtime-specific optimizations.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/neon-serverless.md
Neon JS SDK
Use this for combined Neon Auth + Data API workflows with PostgREST-style querying and typed client setup.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/neon-js.md
Developer Tools
Use this for local development enablement with npx neonctl@latest init, VSCode extension setup, and Neon MCP server configuration.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/devtools.md
Neon CLI
Use this for terminal-first workflows, scripts, and CI/CD automation with neonctl.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/neon-cli.md
Neon Admin API
The Neon Admin API can be used to manage Neon resources programmatically. It is used behind the scenes by the Neon CLI and MCP server, but can also be used directly for more complex automation workflows or when embedding Neon in other applications.
Neon REST API
Use this for direct HTTP automation, endpoint-level control, API key auth, rate-limit handling, and operation polling.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/neon-rest-api.md
Neon TypeScript SDK
Use this when implementing typed programmatic control of Neon resources in TypeScript via @neondatabase/api-client.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/neon-typescript-sdk.md
Neon Python SDK
Use this when implementing programmatic Neon management in Python with the neon-api package.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/neon-python-sdk.md
Neon Auth
Use this for managed user authentication setup, UI components, auth methods, and Neon Auth integration pitfalls in Next.js and React apps.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/neon-auth.md
Neon Auth is also embedded in the Neon JS SDK - so depending on your use case, you may want to use the Neon JS SDK instead of Neon Auth. See https://neon.com/docs/ai/skills/neon-postgres/references/connection-methods.md for more details.
Branching
Use this when the user is planning isolated environments, schema migration testing, preview deployments, or branch lifecycle automation.
Key points:
- - Branches are instant, copy-on-write clones (no full data copy).
- Each branch has its own compute endpoint.
- Use the neonctl CLI or MCP server to create, inspect, and compare branches.
Link: https://neon.com/docs/ai/skills/neon-postgres/references/branching.md
Autoscaling
Use this when the user needs compute to scale automatically with workload and wants guidance on CU sizing and runtime behavior.
Link: https://neon.com/docs/introduction/autoscaling.md
Scale to Zero
Use this when optimizing idle costs and discussing suspend/resume behavior, including cold-start trade-offs.
Key points:
- - Idle computes suspend automatically (default 5 minutes, configurable) (unless disabled - launch & scale plan only)
- First query after suspend typically has a cold-start penalty (around hundreds of ms)
- Storage remains active while compute is suspended.
Link: https://neon.com/docs/introduction/scale-to-zero.md
Instant Restore
Use this when the user needs point-in-time recovery or wants to restore data state without traditional backup restore workflows.
Key points:
- - Restore windows depend on plan limits.
- Users can create branches from historical points-in-time.
- Time Travel queries can be used for historical inspection workflows.
Link: https://neon.com/docs/introduction/branch-restore.md
Read Replicas
Use this for read-heavy workloads where the user needs dedicated read-only compute without duplicating storage.
Key points:
- - Replicas are read-only compute endpoints sharing the same storage.
- Creation is fast and scaling is independent from primary compute.
- Typical use cases: analytics, reporting, and read-heavy APIs.
Link: https://neon.com/docs/introduction/read-replicas.md
Connection Pooling
Use this when the user is in serverless or high-concurrency environments and needs safe, scalable Postgres connection management.
Key points:
- - Neon pooling uses PgBouncer.
- Add
-pooler to endpoint hostnames to use pooled connections. - Pooling is especially important in serverless runtimes with bursty concurrency.
Link: https://neon.com/docs/connect/connection-pooling.md
IP Allow Lists
Use this when the user needs to restrict database access by trusted networks, IPs, or CIDR ranges.
Link: https://neon.com/docs/introduction/ip-allow.md
Logical Replication
Use this when integrating CDC pipelines, external Postgres sync, or replication-based data movement.
Key points:
- - Neon supports native logical replication workflows.
- Useful for replicating to/from external Postgres systems.
Link: https://neon.com/docs/guides/logical-replication-guide.md
Neon Serverless Postgres
Neon 是一个无服务器 Postgres 平台,它将计算与存储分离,提供自动扩缩容、分支、即时恢复和缩容至零功能。它完全兼容 Postgres,可与任何支持 Postgres 的语言、框架或 ORM 配合使用。
Neon 文档
Neon 文档是所有 Neon 相关信息的权威来源。在回复前,请务必对照官方文档验证声明。Neon 的功能和 API 会不断演进,因此建议优先获取当前文档,而非依赖训练数据。
以 Markdown 格式获取文档
任何 Neon 文档页面均可通过两种方式获取为 Markdown 格式:
- 1. 在 URL 后追加 .md(最简单):https://neon.com/docs/introduction/branching.md
- 在标准 URL 上请求 text/markdown:curl -H Accept: text/markdown https://neon.com/docs/introduction/branching
两种方式返回相同的 Markdown 内容。请根据工具支持情况选择合适的方法。
查找正确页面
文档索引列出了每个可用页面及其 URL 和简短描述:
https://neon.com/docs/llms.txt
常见文档 URL 已按以下主题链接组织。如需查找未列出的页面,请搜索文档索引:https://neon.com/docs/llms.txt —— 请勿猜测 URL。
什么是 Neon
在提供实施建议之前,请使用此部分进行架构解释和术语说明(组织、项目、分支、端点)。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/what-is-neon.md
快速入门
用于首次设置:组织/项目选择、连接字符串、驱动安装、可选认证和初始模式设置。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/getting-started.md
连接方式与驱动
当需要根据运行时约束(TCP、HTTP、WebSocket、边缘环境、无服务器、长时间运行)选择正确的传输方式和驱动时使用。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/connection-methods.md
无服务器驱动
用于 @neondatabase/serverless 模式,包括 HTTP 查询、WebSocket 事务和运行时特定优化。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/neon-serverless.md
Neon JS SDK
用于结合 Neon Auth + Data API 的工作流,支持 PostgREST 风格查询和类型化客户端设置。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/neon-js.md
开发者工具
用于通过 npx neonctl@latest init、VSCode 扩展设置和 Neon MCP 服务器配置实现本地开发支持。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/devtools.md
Neon CLI
用于终端优先的工作流、脚本和 CI/CD 自动化,使用 neonctl。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/neon-cli.md
Neon 管理 API
Neon 管理 API 可用于以编程方式管理 Neon 资源。它在后台被 Neon CLI 和 MCP 服务器使用,但也可直接用于更复杂的自动化工作流或当将 Neon 嵌入其他应用程序时。
Neon REST API
用于直接 HTTP 自动化、端点级控制、API 密钥认证、速率限制处理和操作轮询。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/neon-rest-api.md
Neon TypeScript SDK
当需要通过 @neondatabase/api-client 在 TypeScript 中实现对 Neon 资源的类型化编程控制时使用。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/neon-typescript-sdk.md
Neon Python SDK
当需要使用 neon-api 包在 Python 中实现 Neon 的编程管理时使用。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/neon-python-sdk.md
Neon Auth
用于托管用户认证设置、UI 组件、认证方法以及在 Next.js 和 React 应用中的 Neon Auth 集成注意事项。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/neon-auth.md
Neon Auth 也嵌入在 Neon JS SDK 中——因此根据您的用例,您可能希望使用 Neon JS SDK 而非 Neon Auth。详情请参阅 https://neon.com/docs/ai/skills/neon-postgres/references/connection-methods.md。
分支
当用户需要隔离环境、模式迁移测试、预览部署或分支生命周期自动化时使用。
关键点:
- - 分支是即时创建的写时复制克隆(无需完整数据复制)。
- 每个分支拥有自己的计算端点。
- 使用 neonctl CLI 或 MCP 服务器创建、检查和比较分支。
链接:https://neon.com/docs/ai/skills/neon-postgres/references/branching.md
自动扩缩容
当用户需要计算资源随工作负载自动扩展,并希望获得关于 CU 大小和运行时行为的指导时使用。
链接:https://neon.com/docs/introduction/autoscaling.md
缩容至零
当优化空闲成本和讨论挂起/恢复行为(包括冷启动权衡)时使用。
关键点:
- - 空闲计算资源会自动挂起(默认 5 分钟,可配置)(除非禁用——仅限启动和扩展计划)。
- 挂起后的首次查询通常会有冷启动开销(约几百毫秒)。
- 计算资源挂起时,存储仍保持活动状态。
链接:https://neon.com/docs/introduction/scale-to-zero.md
即时恢复
当用户需要时间点恢复或希望无需传统备份恢复工作流即可恢复数据状态时使用。
关键点:
- - 恢复窗口取决于计划限制。
- 用户可以从历史时间点创建分支。
- 时间旅行查询可用于历史检查工作流。
链接:https://neon.com/docs/introduction/branch-restore.md
只读副本
用于读密集型工作负载,用户需要专用只读计算资源而无需复制存储。
关键点:
- - 副本是共享同一存储的只读计算端点。
- 创建速度快,扩缩容独立于主计算资源。
- 典型用例:分析、报告和读密集型 API。
链接:https://neon.com/docs/introduction/read-replicas.md
连接池
当用户处于无服务器或高并发环境,需要安全、可扩展的 Postgres 连接管理时使用。
关键点:
- - Neon 连接池使用 PgBouncer。
- 在端点主机名后添加 -pooler 以使用池化连接。
- 连接池在具有突发性并发的无服务器运行时尤为重要。
链接:https://neon.com/docs/connect/connection-pooling.md
IP 允许列表
当用户需要按受信任网络、IP 或 CIDR 范围限制数据库访问时使用。
链接:https://neon.com/docs/introduction/ip-allow.md
逻辑复制
当集成 CDC 管道、外部 Postgres 同步或基于复制的数据迁移时使用。
关键点:
- - Neon 支持原生逻辑复制工作流。
- 适用于与外部 Postgres 系统之间的复制。
链接:https://neon.com/docs/guides/logical-replication-guide.md