@neon/skills 2.3.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,9 @@ An overview of Neon for apps and agents — Lakebase Postgres, Managed Better Au
26
26
 
27
27
  [![neon-postgres](https://shieldcn.dev/skills/installs/neondatabase/agent-skills/neon-postgres.svg?variant=branded&size=xs&label=neon-postgres)](https://skills.sh/neondatabase/agent-skills/neon-postgres)
28
28
 
29
- A comprehensive index of documentation and best practices for Lakebase Postgres on Neon, to set your agents up for success.
29
+ A comprehensive index of documentation and best practices for Lakebase Postgres on Neon, including branching workflows and egress optimization.
30
+
31
+ > **Migration:** Branching and egress optimization now live in `neon-postgres`. If you previously installed `neon-postgres-branches` or `neon-postgres-egress-optimizer`, update `neon-postgres` and remove those stale local skill directories.
30
32
 
31
33
  ### Neon Auth
32
34
 
@@ -40,18 +42,6 @@ Neon Auth (Managed Better Auth) for login, users, and sessions that branch with
40
42
 
41
43
  For agent platforms, codegen tools, and multi-tenant SaaS products that provision and run Lakebase Postgres, Object Storage, Functions, Managed Better Auth, and/or AI Gateway access for their users. Includes a companion skill and samples in [neondatabase/neon-for-agent-platforms](https://github.com/neondatabase/neon-for-agent-platforms).
42
44
 
43
- ### Neon Postgres Branches
44
-
45
- [![neon-postgres-branches](https://shieldcn.dev/skills/installs/neondatabase/agent-skills/neon-postgres-branches.svg?variant=branded&size=xs&label=neon-postgres-branches)](https://skills.sh/neondatabase/agent-skills/neon-postgres-branches)
46
-
47
- Choose and create the right Neon branch type for migration testing and isolated development workflows, including schema-only branches for sensitive data and reset-from-parent workflows to quickly realign child branches.
48
-
49
- ### Neon Postgres Egress Optimizer
50
-
51
- [![neon-postgres-egress-optimizer](https://shieldcn.dev/skills/installs/neondatabase/agent-skills/neon-postgres-egress-optimizer.svg?variant=branded&size=xs&label=neon-postgres-egress-optimizer)](https://skills.sh/neondatabase/agent-skills/neon-postgres-egress-optimizer)
52
-
53
- Diagnose and fix excessive Postgres egress (network data transfer) in a codebase. Use when investigating high database bills, unexpected data transfer costs, or query overfetching.
54
-
55
45
  ### Neon Object Storage
56
46
 
57
47
  [![neon-object-storage](https://shieldcn.dev/skills/installs/neondatabase/agent-skills/neon-object-storage.svg?variant=branded&size=xs&label=neon-object-storage)](https://skills.sh/neondatabase/agent-skills/neon-object-storage)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neon/skills",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "Agent Skills for Neon: Lakebase Postgres, Managed Better Auth, Realtime, Object Storage, Functions, the Data API, and AI Gateway",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "neon-postgres",
4
- "version": "2.3.0",
4
+ "version": "3.0.0",
5
5
  "description": "Manage your Neon backend with the Neon agent skills and the Neon MCP Server: Lakebase Postgres, Managed Better Auth, Realtime, Object Storage, Functions, the Data API, and AI Gateway",
6
6
  "author": {
7
7
  "name": "Neon",
@@ -12,7 +12,9 @@ description: >-
12
12
  live queries in reactive apps and agents. Also use for object storage, S3,
13
13
  buckets, serverless functions, function triggers, cron, AI gateway, LLM calls,
14
14
  realtime, logs, Loki, Grafana, observability,
15
- postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.
15
+ postgres, database, backend, Claimable Neon, neon.new, a no-signup database,
16
+ or pairing Neon with Upstash for cache, Redis, rate limiting, queues, or
17
+ background jobs.
16
18
  metadata:
17
19
  source: https://github.com/neondatabase/agent-skills/tree/main/skills/neon
18
20
  ---
@@ -55,7 +57,7 @@ For long agent or image streams, mint a JWT on the app server and have the clien
55
57
 
56
58
  **Second best: client-only app with a Functions backend.** Host the SPA on Vercel (or Netlify, Cloudflare, or other app platforms) and call Functions from the browser. For an app using PostgREST or a `supabase-js` database client, prefer migrating database calls to REST endpoints in a Hono Function that queries Lakebase Postgres. Enforce authorization in the Function instead of relying on browser-facing RLS.
57
59
 
58
- Neon provides backend primitives that compose with the app host. Neon does not host the frontend.
60
+ **Small static pages: a `public_read` bucket.** Neon provides backend primitives that compose with a frontend hosting provider like Vercel (or Netlify, Cloudflare, etc.), which ships static hosting and a CDN. Use one for any app frontend. For prototypes and small pages that ship with a Neon backend, a `public_read` Object Storage bucket is enough: Swagger UI, Mastra Studio, OAuth verification screens, sign-in pages for Neon Auth, and personal software. The bucket serves each object at its URL with the `Content-Type` set on upload. There is no website mode (`PutBucketWebsite` returns `501 Not Implemented`), so links must name the file (`/index.html`), and there are no SPA fallbacks or custom domains. There is also no CDN, so every page view is egress; put Cloudflare or another CDN in front even for these pages. See the `neon-object-storage` skill for bucket setup.
59
61
 
60
62
  Offer the Data API only as a Supabase / PostgREST migration path when an existing PostgREST or `supabase-js` database client must keep working. Putting PostgREST in the browser and relying on RLS is easy to get wrong: misconfigured policies expose the database to the client. Do not recommend this for new apps. An installed Supabase package used only for Auth or Storage does not establish a database-client dependency. Route generic REST endpoint requests to a Function or existing app handler.
61
63
 
@@ -86,12 +88,16 @@ New projects are created in AWS regions. Prefer pooled `DATABASE_URL` for applic
86
88
  | HTTP APIs, cron, custom WebSocket or SSE push, long-running agents | Functions querying Postgres |
87
89
  | Live queries for realtime, reactive apps and agents; optimistic mutations | `neon-realtime` (`preview.realtime` in `neon.ts`). Not available on Claimable projects until claimed |
88
90
  | LLM calls | AI Gateway |
91
+ | Caching hot reads, rate limits | Upstash Redis |
92
+ | Background jobs, queues, retries, delayed delivery | Upstash QStash delivering to a Function |
89
93
  | SQL, schema, inspect, search | `neon-postgres` |
90
94
  | Existing PostgREST / Supabase database client | Data API (`dataApi` in `neon.ts`) |
91
95
  | Generic REST endpoints | Function or existing handler, not Data API |
92
96
 
93
97
  Use `neon-auth` to choose identity and to implement Managed Better Auth; the [Auth guide](references/auth.md) points there. Keep existing Better Auth, Clerk, and Supabase Auth unless the user asked to migrate login. Auth cannot be enabled on a project with IP Allow or Private Networking.
94
98
 
99
+ Neon has no built-in key-value store or message queue. For a cache, rate limiting, or background jobs, pair it with Upstash Redis and QStash, and keep any Redis or queue the app already uses.
100
+
95
101
  ## Neon Documentation
96
102
 
97
103
  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.
@@ -121,14 +127,12 @@ The skills below live in the [`neondatabase/agent-skills`](https://github.com/ne
121
127
 
122
128
  | Skill | Use it for |
123
129
  | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
124
- | `neon-postgres` | Working with databases, including connections, schemas, queries, search, and autoscaling: SQL development, schema design, performance optimization, and scaling decisions. |
130
+ | `neon-postgres` | Working with databases, including connections, schemas, queries, search, branching workflows, egress optimization, autoscaling, performance, and scaling decisions. |
125
131
  | `neon-auth` | Identity routing and Managed Better Auth setup (login, users, sessions, trusted domains). Fetch: https://neon.com/docs/ai/skills/neon-auth/SKILL.md |
126
- | `neon-postgres-branches` | Choosing or creating the right branch type for dev, preview, test, or CI workflows. Use this skill as a slash command. |
127
132
  | `neon-object-storage` | Storing and serving files (uploads, images, blobs), including branching them with the database. |
128
133
  | `neon-functions` | Deploying long-running or streaming serverless functions — APIs, agents, SSE/WebSocket servers, and Function Triggers (cron and object-storage). |
129
134
  | `neon-ai-gateway` | Calling an LLM or routing across model providers with one credential, including discovering the branch's servable models at runtime via the OpenAI-compatible `/v1/models` endpoint. |
130
135
  | `neon-realtime` | Realtime makes any SQL query live, for realtime, reactive apps and agents: enabling Realtime, sealing queries, React and TanStack DB bindings, SSR, and optimistic mutations. |
131
- | `neon-postgres-egress-optimizer` | Diagnosing or fixing excessive Postgres egress (network data-transfer) costs in a codebase. |
132
136
 
133
137
  There is no `neon-data-api` skill. Configure `dataApi` in `neon.ts` only for PostgREST / Supabase database-client compatibility or a migration that already depends on it.
134
138
 
@@ -166,9 +170,20 @@ If the Neon CLI is not available, you can visit https://neon.com/.well-known/age
166
170
 
167
171
  ### Updating Skills
168
172
 
169
- Keep the skills up to date: for every new session, update them so you are working with the latest best practices.
173
+ Keep the skills up to date: for every new session, check them and update the stale ones so you are working with the latest best practices.
174
+
175
+ Run `neon skills status` (neon 8.12.0 or newer) to check the Neon skills in this directory's `skills-lock.json`, or `neon skills status --global` for user-level skills. It lists each skill as `up to date`, `outdated`, or `not found upstream`, and prints the update command when any are outdated. It exits 0 either way, so read the Status column:
176
+
177
+ ```
178
+ $ neon skills status
179
+ Skills
180
+ Scope Skill Status
181
+ this directory neon outdated
182
+ this directory neon-postgres up to date
183
+ Update them: neon skills update -y
184
+ ```
170
185
 
171
- Run `neon skills update` to update all installed Neon skills, or `neon skills update -y` to skip prompts. If the skills were installed via a plugin, they are updated automatically.
186
+ Run `neon skills update` to update all installed Neon skills, or `neon skills update -y` to skip prompts. Add `--global` for user-level skills. If the skills were installed via a plugin, they are updated automatically.
172
187
 
173
188
  ## Getting Started with Neon
174
189
 
@@ -13,7 +13,8 @@ description: >-
13
13
  "add AI to my app", "chat completion", "model routing", "LLM proxy/gateway",
14
14
  "one API for all
15
15
  models", "use Claude/GPT/Gemini", "AI SDK", "Mastra agent", "Neon AI
16
- Gateway", "generate embeddings", and "log/rate-limit AI calls".
16
+ Gateway", "generate embeddings", "generate images", and "log/rate-limit AI
17
+ calls".
17
18
  metadata:
18
19
  parent: neon
19
20
  source: https://github.com/neondatabase/agent-skills/tree/main/skills/neon-ai-gateway
@@ -58,16 +59,16 @@ If the user already has a deep, single-provider integration and no interest in N
58
59
 
59
60
  Check these preconditions before setting anything up:
60
61
 
61
- The AI Gateway is currently available in `aws-us-east-2`, `aws-us-east-1`, `aws-eu-central-1`, and `aws-ap-southeast-1`. Foundation model access requires a paid Neon plan. Confirm the user's project is in one of these regions.
62
+ The AI Gateway is currently available in `aws-us-east-2`, `aws-us-east-1`, `aws-eu-central-1`, and `aws-ap-southeast-1`. Confirm the user's project is in one of these regions.
62
63
 
63
- ### Enabling the gateway: plan and model-catalog gating
64
+ The AI Gateway is available on paid Neon plans only (Launch and Scale) and draws down prepaid AI Gateway credits. Any paid account with prepaid credits can call every model in the catalog. See https://neon.com/docs/ai-gateway/prepaid-credits.md.
64
65
 
65
- The AI Gateway is credential-gated rather than a provisioning step, but two plan limits gate it — one blocks provisioning, the other only trims the catalog — and the CLI surfaces each:
66
+ ### Enabling the gateway: plan and model access
66
67
 
67
- - **Free plan → provisioning is blocked.** `neon config apply` / `deploy` and `neon checkout` **refuse** to enable the gateway on a Free plan (the gateway can't serve requests there), with a friendly "upgrade to a paid plan, or remove `aiGateway`" error. A dry-run `neon config plan` and `neon env pull` don't provision, so they only **warn**. So: to use the gateway the project's account must be on a paid Neon plan.
68
- - **Paid plan with a reduced model catalog.** On a paid plan the gateway provisions and serves, but an account can start with a trimmed catalog — some flagship models (e.g. Anthropic Opus, OpenAI Codex / `*-pro`) are missing from `GET /v1/models`. This is expected; `neon env pull` (and the env pull bundled into `apply` / `deploy` / `checkout`) warns and links the user to their branch's AI Gateway page in the Neon Console (`https://console.neon.tech/app/projects/<project-id>/branches/<branch-id>/ai-gateway`) to request access to more models. Verify what's actually available for the branch by reading `/v1/models` (see the models section below) rather than assuming the full catalog.
68
+ The AI Gateway is credential-gated rather than a provisioning step. The CLI surfaces both plan and model-access limits:
69
69
 
70
- When helping a user debug "the gateway isn't working" or "a model is missing", use `/v1/models` plus the account's plan to distinguish these two cases — a Free plan blocks provisioning entirely, while a reduced catalog on a paid plan just needs a model-access request.
70
+ - **Free plan → provisioning is blocked.** `neon config apply` / `deploy` and `neon checkout` **refuse** to enable the gateway on a Free plan (the gateway can't serve requests there), with a friendly "upgrade to a paid plan, or remove `aiGateway`" error. A dry-run `neon config plan` and `neon env pull` don't provision, so they only **warn**. So: to use the gateway the project's account must be on a paid Neon plan.
71
+ - **Paid plan with locked models.** `GET /v1/models` lists every catalog model and marks the ones the account can't call yet with `enabled: false`. `neon env pull` (and the env pull bundled into `apply` / `deploy` / `checkout`) warns when some models are enabled but no flagship model (e.g. Anthropic Opus, OpenAI Codex / `*-pro`) is among them, and links to the branch's AI Gateway page in the Neon Console (`https://console.neon.tech/app/projects/<project-id>/branches/<branch-id>/ai-gateway`). That page lists locked models under **Some models are restricted**, grouped by reason, each with its fix: **Upgrade plan** for a paid plan, **Add credits** for prepaid credits, or Support for an account restriction or a model not available to the account. After the user upgrades or buys credits, models unlock once Neon confirms access. No CLI warning does not mean every model is enabled; check the model's `enabled` value. See https://neon.com/docs/ai-gateway/troubleshooting.md.
71
72
 
72
73
  ## Setup
73
74
 
@@ -124,17 +125,18 @@ For typed, validated access to the injected credentials, pass the same `neon.ts`
124
125
 
125
126
  The [Vercel AI SDK](https://ai-sdk.dev) is the recommended way to call the gateway and build agents from TypeScript: one set of primitives (`generateText`, `streamText`, tool calling, structured output) over every catalog model, with first-class streaming for the long agent responses Neon Functions are built to host.
126
127
 
127
- The dedicated `@neon/ai-sdk-provider` reads `NEON_AI_GATEWAY_BASE_URL` + `NEON_AI_GATEWAY_TOKEN` from the injected env with **zero config** and routes each model to the best endpoint (Anthropic → Messages, OpenAI/Codex → Responses, everything else → MLflow). On a Neon Function that streams text and generates images, just pick a catalog model:
128
+ The dedicated `@neon/ai-sdk-provider` reads `NEON_AI_GATEWAY_BASE_URL` + `NEON_AI_GATEWAY_TOKEN` from the injected env with **zero config** and routes each model to the best endpoint (Anthropic → Messages, OpenAI/Codex → Responses, everything else → MLflow). On a Neon Function that streams text and generates images, pick an OpenAI catalog model, since the image tool runs on the Responses route:
128
129
 
129
130
  ```typescript
130
131
  import { neon } from "@neon/ai-sdk-provider";
131
132
  import { streamText } from "ai";
132
133
 
133
134
  const result = streamText({
134
- model: neon("gpt-5-mini"), // or claude-sonnet-4-6, gemini-3-flash, ...
135
+ model: neon("gpt-5-mini"),
135
136
  messages,
136
137
  tools: {
137
138
  image_generation: neon.tools.imageGeneration({
139
+ model: "gpt-image-2",
138
140
  outputFormat: "jpeg",
139
141
  size: "1024x1024",
140
142
  }),
@@ -180,6 +182,37 @@ const { text } = await generateText({
180
182
 
181
183
  For a full AI SDK agent deployed as a Neon Function (streaming, tool calling, image generation, persistence), see the `neon-functions` skill's [references/ai-sdk.md](https://neon.com/docs/ai/skills/neon-functions/references/ai-sdk.md).
182
184
 
185
+ ## Generate Images
186
+
187
+ Images come from the OpenAI Responses `image_generation` built-in tool on an OpenAI model, on the `/openai/v1/responses` route. The gateway has no image model endpoint, so the AI SDK's `generateImage()` throws `NoSuchModelError`. Every image request follows two rules:
188
+
189
+ - **Use a supported image model.** The gateway supports `gpt-image-2`, `gpt-image-1.5`, and `gpt-image-1-mini`. Set `model` explicitly on every tool definition, and use `gpt-image-2` unless the user asks for another.
190
+ - **Always stream.** A non-streaming response whose image is over 655,360 bytes fails with `400: The response content length cannot be greater than 655360 bytes long`, and most images are larger than that. Use `streamText`, never `generateText`, when the image tool is attached. With the plain OpenAI SDK, pass `stream: true` to `client.responses.create()`.
191
+
192
+ ```typescript
193
+ import { neon } from "@neon/ai-sdk-provider";
194
+ import { streamText } from "ai";
195
+
196
+ const result = streamText({
197
+ model: neon("gpt-5-mini"),
198
+ prompt: "Generate an image of a red apple on a wooden table",
199
+ tools: {
200
+ image_generation: neon.tools.imageGeneration({ model: "gpt-image-2" }),
201
+ },
202
+ });
203
+
204
+ for await (const part of result.fullStream) {
205
+ if (
206
+ part.type === "tool-result" &&
207
+ !part.dynamic &&
208
+ "result" in part.output &&
209
+ typeof part.output.result === "string"
210
+ ) {
211
+ const png = Buffer.from(part.output.result, "base64"); // save or upload it
212
+ }
213
+ }
214
+ ```
215
+
183
216
  ## Generate Embeddings with the AI SDK
184
217
 
185
218
  Use `@neon/ai-sdk-provider` 1.0.0+ with AI SDK 6+ for embedding calls. `neon.embeddingModel()` reads the same injected gateway variables as the language models:
@@ -323,7 +356,7 @@ Any Neon credential (`nt_live_...`) valid for the branch works as the bearer tok
323
356
  }
324
357
  ```
325
358
 
326
- > Note: `context_length`, `pricing`, and `per_request_limits` are currently `null` and `created` is `0` for every entry — for context windows, pricing, and capabilities use the models.dev catalog above. Use `/v1/models` when you need the live, branch-scoped list of servable model IDs (e.g. to populate a model picker or validate a `model` before a request).
359
+ > Note: `context_length`, `pricing`, and `per_request_limits` are currently `null` and `created` is `0` for every entry — for context windows, pricing, and capabilities use the models.dev catalog above. Use `/v1/models` when you need the live, branch-scoped list of servable model IDs (e.g. to populate a model picker or validate a `model` before a request), and keep only entries with `enabled: true`.
327
360
 
328
361
  ## Neon Documentation
329
362
 
@@ -3,13 +3,14 @@ name: neon-auth
3
3
  description: >-
4
4
  Add authentication to a new app. Use for "add auth", "add login", Neon Auth
5
5
  (Managed Better Auth), identity routing, sign-up, sign-in, password reset,
6
- email OTP, magic links, organizations, phone OTP, OAuth, passkeys, MFA,
7
- trusted domains, invalid domain, and @neondatabase/auth. No existing identity:
6
+ email OTP, magic links, organizations, phone OTP, OAuth, OAuth server for MCP
7
+ or third-party OAuth clients, passkeys, MFA,
8
+ trusted domains, invalid domain, and @neon/auth. No existing identity:
8
9
  default to Managed Better Auth. Keep working Better Auth, Clerk, Supabase
9
10
  Auth, or another IdP. User asked to migrate from Supabase Auth: Managed
10
11
  Better Auth. A required plugin outside Managed support: self-managed Better
11
12
  Auth on a Neon Function or the existing app host. Also use for auth APIs in
12
- @neondatabase/neon-js.
13
+ @neon/neon-js.
13
14
  metadata:
14
15
  parent: neon
15
16
  source: https://github.com/neondatabase/agent-skills/tree/main/skills/neon-auth
@@ -25,7 +26,7 @@ neon skills -s neon -y
25
26
 
26
27
  # Neon Auth
27
28
 
28
- Neon Auth is Managed Better Auth: users, sessions, and auth config live in the `neon_auth` schema on the branch's Lakebase Postgres, and auth state branches with the database. The client API is the Better Auth method set (`signIn.email`, `signIn.social`, `getSession`) through `@neondatabase/auth`. That wrapper is not a drop-in for bare `better-auth/client`: it pins the plugin list and adds Neon-specific OAuth verifier, iframe popup, and JWT handling. Stay on the wrapper while Auth is managed.
29
+ Neon Auth is Managed Better Auth: users, sessions, and auth config live in the `neon_auth` schema on the branch's Lakebase Postgres, and auth state branches with the database. The client API is the Better Auth method set (`signIn.email`, `signIn.social`, `getSession`) through `@neon/auth`. That wrapper is not a drop-in for bare `better-auth/client`: it pins the plugin list and adds Neon-specific OAuth verifier, iframe popup, and JWT handling. Stay on the wrapper while Auth is managed.
29
30
 
30
31
  This skill chooses identity, then implements Managed Better Auth. It does not replace a working auth server in order to use Postgres, Functions, Object Storage, or the AI Gateway.
31
32
 
@@ -41,18 +42,18 @@ Inspect existing identity and the required login features before provisioning. A
41
42
  | User asked to migrate from Supabase Auth | Managed Better Auth. [Supabase Auth](#supabase-auth). Moving only Postgres or adding a Function keeps Supabase Auth. |
42
43
  | Clerk, Auth.js, Supabase Auth, or another working IdP | Keep it unless the user asks to migrate. |
43
44
 
44
- Google, GitHub, and Vercel social OAuth are offered on Managed Auth. They are not a reason to leave Managed Auth. Other OAuth providers, generic OAuth, MFA, passkeys, API keys, MCP OAuth, SSO, custom plugins, hooks, and custom JWT claims are the [plugin matrix](#plugin-support) check.
45
+ Google, GitHub, Microsoft, Vercel, and Apple social OAuth are offered on Managed Auth. They are not a reason to leave Managed Auth. Microsoft and Apple need your own credentials: [Apple and Microsoft OAuth](#apple-and-microsoft-oauth). Making Neon Auth the OAuth server for your own MCP server or third-party OAuth clients is supported: [references/oauth-server.md](references/oauth-server.md). Other OAuth providers, generic OAuth, MFA, passkeys, API keys, SSO, custom plugins, hooks, and custom JWT claims are the [plugin matrix](#plugin-support) check.
45
46
 
46
47
  Before enabling Managed Auth, confirm the project is on AWS and does not use IP Allow or Private Networking. Leave those protections in place.
47
48
 
48
- Configure supported Managed plugins through Neon (Console, API, or `neon neon-auth`), not by passing `plugins` into `@neondatabase/auth`. Enabling `auth: true` is not implementing login.
49
+ Configure supported Managed plugins through Neon (Console, API, or `neon neon-auth`), not by passing `plugins` into `@neon/auth`. Enabling `auth: true` is not implementing login.
49
50
 
50
51
  ## What It Does
51
52
 
52
53
  - **Managed identity in Postgres** — users and sessions in `neon_auth`, queryable with SQL, compatible with RLS.
53
54
  - **Auth emails without an app mailer** — verification, email OTP, magic links, and password reset. Getting started uses shared SMTP (`auth@mail.myneon.app`). You do not add Resend or SendGrid to implement login. Production needs custom SMTP: https://neon.com/docs/auth/production-checklist.md
54
55
  - **Branches with the database** — each branch has its own Auth URL and isolated auth state.
55
- - **Better Auth client methods via the Neon SDK** — `@neondatabase/auth` (auth only) or `@neondatabase/neon-js/auth` (combined SDK). Optional UI: `@neondatabase/auth-ui`.
56
+ - **Better Auth client methods via the Neon SDK** — `@neon/auth` (auth only) or `@neon/neon-js/auth` (combined SDK). Optional UI: Better Auth UI (`@better-auth-ui/react` with its shadcn/ui components).
56
57
  - **Fixed plugin set** — the Managed client does not accept a `plugins` option. See [plugin support](#plugin-support).
57
58
 
58
59
  ## Availability
@@ -80,7 +81,7 @@ neon neon-auth status
80
81
 
81
82
  If Function env in that config reads `process.env`, use `neon deploy --env <file>` as the parent skill describes. The manual service command is `neon neon-auth enable`; do not run both enable and deploy as redundant required steps when `neon.ts` already declares `auth: true`.
82
83
 
83
- Then implement login: [references/managed-auth.md](references/managed-auth.md).
84
+ Then implement login: [references/managed-auth.md](references/managed-auth.md). To make Neon Auth the OAuth server for an MCP server or OAuth clients, continue to [references/oauth-server.md](references/oauth-server.md).
84
85
 
85
86
  Claimable projects: follow the parent Claimable path, then `auth: true` and `neon deploy` when login is requested and no existing provider should be preserved.
86
87
 
@@ -106,14 +107,14 @@ A required plugin on the self-managed path is verified in that app's Better Auth
106
107
 
107
108
  ## Plugin support
108
109
 
109
- Checked 2026-09-17 against https://neon.com/docs/auth/guides/plugins.md, https://neon.com/docs/auth/roadmap.md, and the `@neondatabase/auth` client plugin list. Re-fetch those pages if this skill may be stale. An unlisted upstream plugin needs a live check; do not treat absence from this table as a dated roadmap item.
110
+ Checked 2026-10-30 against https://neon.com/docs/auth/guides/plugins.md, https://neon.com/docs/auth/guides/plugins/oauth-provider.md, https://neon.com/docs/auth/roadmap.md, and the `@neon/auth` client plugin list. Re-fetch those pages if this skill may be stale. An unlisted upstream plugin needs a live check; do not treat absence from this table as a dated roadmap item.
110
111
 
111
112
  "Not exposed" means the Managed SDK/UI contract. It is not a claim that every raw server request was tested.
112
113
 
113
114
  | Feature | Managed Auth | Boundary |
114
115
  | --- | --- | --- |
115
116
  | Email/password | Supported | `signUp.email`, `signIn.email` |
116
- | Social OAuth (Google, GitHub, Vercel) | Supported | `signIn.social`. Shared Google credentials are for development; production and GitHub/Vercel need your own OAuth apps. https://neon.com/docs/auth/guides/setup-oauth.md |
117
+ | Social OAuth (Google, GitHub, Microsoft, Vercel, Apple) | Supported | `signIn.social`. Shared Google credentials are for development; production and GitHub/Vercel need your own OAuth apps. Microsoft and Apple always need your own ([details](#apple-and-microsoft-oauth)). https://neon.com/docs/auth/guides/setup-oauth.md |
117
118
  | Admin | Supported | Admin session required. Plugin customization is on the roadmap. |
118
119
  | Email OTP | Supported | Managed delivery. `emailOtp.sendVerificationOtp`, `signIn.emailOtp`. |
119
120
  | Magic Link | Supported | Enable on the branch (off by default). `signIn.magicLink`. |
@@ -122,14 +123,22 @@ Checked 2026-09-17 against https://neon.com/docs/auth/guides/plugins.md, https:/
122
123
  | Open API | Supported | Server routes `/reference` and `/open-api/generate-schema`. |
123
124
  | Phone Number | Supported with constraints | Browser client: existing users link a number, then sign in; no phone-first signup; own SMS webhook; custom UI. Next.js `auth.handler()` forwards the catch-all path, including phone OTP. A missing `auth.phoneNumber` server method is a missing typed helper, not a proxy rejection. https://neon.com/docs/auth/guides/plugins/phone-number.md |
124
125
  | MFA / Two-Factor | Roadmap | Unavailable on Managed Auth. If required: [self-managed.md](references/self-managed.md), after confirming the installed Better Auth version. |
125
- | Passkey, API Key, Generic OAuth, One Tap, Multi Session | Not exposed by Managed SDK/UI | If required: [self-managed.md](references/self-managed.md). Generic OAuth is not Google/GitHub/Vercel social sign-in. |
126
- | MCP / OAuth Provider | Not Managed Auth | Third-party MCP clients self-authorizing against your server. Keep existing login. See `neon-functions` [references/mcp.md](https://neon.com/docs/ai/skills/neon-functions/references/mcp.md). |
126
+ | Passkey, API Key, Generic OAuth, One Tap, Multi Session | Not exposed by Managed SDK/UI | If required: [self-managed.md](references/self-managed.md). Generic OAuth is not Google/GitHub/Microsoft/Vercel/Apple social sign-in. |
127
+ | OAuth Provider (OAuth server, MCP auth) | Supported (beta) | Neon Auth is the OAuth 2.1 / OIDC server for your MCP server or third-party OAuth clients. You host the login and consent pages; no client credentials grant. See [references/oauth-server.md](references/oauth-server.md). |
127
128
  | SSO / SAML | Not listed or exposed | If required: [self-managed.md](references/self-managed.md), after confirming the installed Better Auth version. |
128
129
 
129
130
  The default Managed client method is `getAnonymousToken()`. That JWT is a Neon anonymous Data API token. It is not Better Auth's Anonymous-account plugin (`signIn.anonymous`). `anonymousTokenClient()` is the SDK plugin factory, not a method on the public client. Do not call it, and do not call `getAnonymousToken()` on `SupabaseAuthAdapter()`.
130
131
 
131
132
  Trusted domains and webhooks are Neon settings, not installable Better Auth plugins.
132
133
 
134
+ ## Apple and Microsoft OAuth
135
+
136
+ Both providers reject shared credentials; add them with your own via `neon neon-auth oauth-provider add|update` (Console and API work too). A multi-line secret goes in a file with `--oauth-client-secret-file`, not inline.
137
+
138
+ - **Apple**: `client_id` is the Services ID, `client_secret` is the full `.p8` private key. Also pass `--apple-team-id` and `--apple-key-id` (10 characters). Neon Auth signs the client-secret JWT itself, so there is nothing to rotate. Rotating the key needs the new `--apple-key-id` in the same update. The return URL must be HTTPS (`https://<auth host>/<db>/auth/callback/apple`); Apple rejects localhost, so test through a tunnel or a deployed preview.
139
+ - **Microsoft**: `client_id` and `client_secret` from the Entra app registration. `--microsoft-tenant-id` is optional: `common` (default), `organizations`, `consumers`, a tenant GUID, or a domain. The redirect URI is `<base_url>/callback/microsoft`.
140
+ - **Microsoft email verification**: an email counts as verified only when the ID token carries `xms_edov` = true and `acct` = 0. Add `xms_edov` and `acct` as optional ID-token claims in Entra. Without them, a same-email existing user gets `account_not_linked`, `link-social` fails with `unable_to_link_account`, and new users stay unverified.
141
+
133
142
  ## Trusted domains
134
143
 
135
144
  Auth redirects only to origins on its allowlist. `invalid domain` means the app origin is missing. Include the scheme, omit a trailing slash, register production and preview origins before pointing users at them, and target the correct branch:
@@ -23,9 +23,9 @@ SMS is separate: the Phone Number plugin needs an application `send.otp` webhook
23
23
 
24
24
  | Need | Package |
25
25
  | --- | --- |
26
- | Auth only | `@neondatabase/auth` |
27
- | Already using the combined SDK | `@neondatabase/neon-js/auth` re-export |
28
- | Pre-built UI | `@neondatabase/auth-ui` |
26
+ | Auth only | `@neon/auth` |
27
+ | Already using the combined SDK | `@neon/neon-js/auth` re-export |
28
+ | Pre-built UI | Better Auth UI: `@better-auth-ui/react` plus shadcn/ui components (`npx shadcn add @better-auth-ui/auth`) |
29
29
 
30
30
  Keep an existing `SupabaseAuthAdapter()` caller on that API (`signInWithPassword`, `signInWithOAuth`). Do not mix those methods into default Better Auth examples. Password hashes do not migrate from Supabase; `updateUser()` cannot change email or password; email verification needs app UI. Guide: https://neon.com/docs/auth/migrate/from-supabase.md
31
31
 
@@ -44,10 +44,10 @@ The Managed client is Better Auth methods through Neon's wrapper. It is not inte
44
44
 
45
45
  ## Next.js
46
46
 
47
- `createNeonAuth` from `@neondatabase/auth/next/server`. Optional Next peer on current `@neondatabase/auth` is `>=16.0.0`; check the installed package before changing an existing app's router file.
47
+ `createNeonAuth` from `@neon/auth/next/server`. Optional Next peer on current `@neon/auth` is `>=16.0.0`; check the installed package before changing an existing app's router file.
48
48
 
49
49
  ```typescript
50
- import { createNeonAuth } from "@neondatabase/auth/next/server";
50
+ import { createNeonAuth } from "@neon/auth/next/server";
51
51
 
52
52
  export const auth = createNeonAuth({
53
53
  baseUrl: process.env.NEON_AUTH_BASE_URL!,
@@ -68,24 +68,31 @@ Those five methods are what the installed SDK returns. Existing apps that export
68
68
  Browser client takes **no arguments** and talks to that same-origin proxy:
69
69
 
70
70
  ```typescript
71
- import { createAuthClient } from "@neondatabase/auth/next";
71
+ import { createAuthClient } from "@neon/auth/next";
72
72
 
73
73
  export const authClient = createAuthClient();
74
74
  ```
75
75
 
76
- Protect routes with `auth.middleware({ loginUrl: "/auth/sign-in" })` from `proxy.ts` on Next 16. Earlier Next apps may still use `middleware.ts`; match the installed SDK. Always set `config.matcher` to the protected pages. A matcher that covers every path redirects JavaScript and CSS for unauthenticated visitors, so the login page cannot load:
76
+ ### Middleware
77
+
78
+ Protect routes with `auth.middleware()` from `proxy.ts` on Next 16. Earlier Next apps may still use `middleware.ts`; match the installed SDK. Use the catch-all matcher and list only the app's own public pages in `publicRoutes`:
77
79
 
78
80
  ```typescript
79
81
  import { auth } from "@/lib/auth/server";
80
82
 
81
- export default auth.middleware({ loginUrl: "/auth/sign-in" });
83
+ export default auth.middleware({
84
+ loginUrl: "/auth/sign-in",
85
+ publicRoutes: ["/"],
86
+ });
82
87
 
83
88
  export const config = {
84
- matcher: ["/account/:path*"],
89
+ matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
85
90
  };
86
91
  ```
87
92
 
88
- Replace `/account/:path*` with the app's protected routes. Keep login, registration, recovery, `/api/auth`, and static assets accessible without a session.
93
+ - `/api/auth` and every Better Auth UI signed-out view (sign-in, sign-up, forgot-password, reset-password, verify-email, magic-link, accept-invitation, and the rest) are public by default. `/auth` itself and `/settings/*` stay protected.
94
+ - `publicRoutes` matches an exact path or its slash-delimited subpaths. `"/"` matches only `/`. Entries must start with `/`; `""` and `"//"` throw.
95
+ - Do not write a custom `proxy.ts` wrapper or re-list the default skip routes.
89
96
 
90
97
  Before reading protected data or performing a mutation, check the session inside the Route Handler or Server Action and enforce the resource's authorization rules. Verify direct unauthenticated requests are denied, independently of page redirects:
91
98
 
@@ -111,19 +118,21 @@ JWT: `const { data, error } = await auth.token();` then `data.token`. Do not cal
111
118
 
112
119
  ## Organization invitations
113
120
 
114
- `organization.inviteMember()` does not send email unless `send_invitation_email` is on (default `false`) and "Verify email at signup" is enabled. Accepting an emailed invite needs `/auth/accept-invitation?invitationId=` via `AuthView` or a custom flow that signs the recipient in and calls `organization.acceptInvitation({ invitationId })`. If email delivery stays off, use an in-app invitation list. https://neon.com/docs/auth/guides/plugins/organization.md
121
+ `organization.inviteMember()` does not send email unless `send_invitation_email` is on (default `false`) and "Verify email at signup" is enabled. Accepting an emailed invite needs `/auth/accept-invitation?invitationId=` via Better Auth UI's organization plugin (`organizationPlugin()`, view `accept-invitation`) or a custom flow that signs the recipient in and calls `organization.acceptInvitation({ invitationId })`. If email delivery stays off, use an in-app invitation list. https://neon.com/docs/auth/guides/plugins/organization.md
115
122
 
116
123
  ## React / Vite
117
124
 
118
125
  ```typescript
119
- import { createAuthClient } from "@neondatabase/auth";
120
- import { BetterAuthReactAdapter } from "@neondatabase/auth/react/adapters";
126
+ import { createAuthClient } from "@neon/auth";
127
+ import { BetterAuthReactAdapter } from "@neon/auth/react/adapters";
121
128
 
122
129
  export const authClient = createAuthClient(import.meta.env.VITE_NEON_AUTH_URL, {
123
130
  adapter: BetterAuthReactAdapter(),
124
131
  });
125
132
  ```
126
133
 
134
+ Vite has no server middleware. Guard protected routes with a session check, for example a router loader that calls `authClient.getSession()` or `useSession()` in a layout component, and redirect to `/auth/sign-in` when there is no user. Add `http://localhost:5173` and the production origin as trusted domains first: see [Trusted domains](../SKILL.md#trusted-domains).
135
+
127
136
  Call adapter factories with `()`. Omit the adapter for vanilla Better Auth methods without `useSession`.
128
137
 
129
138
  Public calls: `signUp.email({ email, password, name })`, `signIn.email({ email, password })`, `signIn.social({ provider, callbackURL })`, `getSession()`, `signOut()`. Result shape is `{ data, error }`; user is `data.user`. Handle `error` and thrown HTTP errors, pending UI, and authenticated vs unauthenticated display.
@@ -132,16 +141,65 @@ JWT: `authClient.token()` then `data.token`.
132
141
 
133
142
  ## UI
134
143
 
135
- ```typescript
136
- import "@neondatabase/auth-ui/css";
137
- import { NeonAuthUIProvider, AuthView } from "@neondatabase/auth-ui";
144
+ Neon hosts the auth server. Do NOT call `betterAuth()`, add a database adapter, or run Better Auth migrations.
145
+
146
+ Better Auth UI 1.7. The shadcn CLI copies its components into the app; `@better-auth-ui/react` is the data layer and needs TanStack Query:
147
+
148
+ ```bash
149
+ npx shadcn@latest init # once, if the app has no components.json
150
+ npx shadcn@latest add @better-auth-ui/auth # sign-in, sign-up, password reset
151
+ npx shadcn@latest add @better-auth-ui/user-button # optional
152
+ ```
153
+
154
+ ```tsx
155
+ import { getSafeRedirectTo, viewPaths } from "@better-auth-ui/core";
156
+ import { QueryClientProvider } from "@tanstack/react-query";
157
+ import { AuthProvider } from "@/components/auth/auth-provider";
158
+ import { Auth } from "@/components/auth/auth";
159
+ import { Toaster } from "@/components/ui/sonner";
160
+
161
+ <QueryClientProvider client={queryClient}>
162
+ <AuthProvider
163
+ authClient={authClient}
164
+ emailAndPassword={{ requireEmailVerification: false }} // match the branch's "Verify email at signup"
165
+ navigate={({ to, replace }) => {
166
+ const path = getSafeRedirectTo(to, window.location.origin);
167
+ const target = path.startsWith("//") ? "/" : path;
168
+ if (replace) router.replace(target);
169
+ else router.push(target);
170
+ }}
171
+ Link={Link}
172
+ redirectTo="/"
173
+ >
174
+ {children}
175
+ <Toaster />
176
+ </AuthProvider>
177
+ </QueryClientProvider>
178
+
179
+ // /auth/[path]: valid paths are Object.values(viewPaths.auth)
180
+ <Auth path={path} />
138
181
  ```
139
182
 
140
- Choose one CSS import: `/css` or `/tailwind`, never both. Current `@neondatabase/auth-ui` uses `<AuthView path={path} />`. Check installed types before copying a `pathname` example from older docs.
183
+ - `queryClient`, `router` and `Link` are the app's own TanStack Query client and its framework router's `push`/`replace` and `Link`; do not invent imports for them.
184
+ - Pass the Neon `authClient` as is; it satisfies Better Auth UI's `AuthClient` type.
185
+ - `navigate` receives the URL's `?redirectTo=` after sign-in. Validate it as above: `getSafeRedirectTo` alone returns `//host` for `/a/..//host`.
186
+ - Install with one command and let npm resolve it: `npm i @neon/auth @better-auth-ui/core @better-auth-ui/react @tanstack/react-query`. `@neon/auth` declares the Better Auth range, so npm installs a single compatible copy. Do not pin `better-auth` or its plugins, and do not add `overrides` or `resolutions`.
187
+ - After the last `npx shadcn add`, run `npm i better-auth@~1.7.12`. The registry items install a bare `better-auth`, which resolves to a newer prerelease and leaves two copies; this range matches `@neon/auth`.
188
+ - Protect pages on the server (`auth.middleware()`, see [Middleware](#middleware)). Better Auth UI's `useAuthenticate` redirects while a stale signed-out session is still refetching, which sends a user who just signed up back to sign-in.
189
+ - Render `<Toaster />`: the copied `AuthProvider` reports errors with Sonner's `toast.error()` and renders nothing itself.
190
+ - Set `requireEmailVerification` to the branch's "Verify email at signup" setting (off by default). It decides whether sign-up shows the verify-email view.
191
+ - Better Auth UI plugins (`plugins={[...]}`) do not enable the Managed plugin. Configure the plugin on the branch, then the UI.
192
+
193
+ Verify before reporting done:
141
194
 
142
- UI flags (`emailOTP`, `magicLink`, social providers, organization) do not enable the Managed plugin. Configure the plugin on the branch, then the UI.
195
+ 1. Sign up a new user.
196
+ 2. Sign out, then sign in again.
197
+ 3. The session survives a reload.
198
+ 4. A protected route redirects to `/auth/sign-in` while signed out.
199
+ 5. A wrong password shows an invalid-credentials message, not a generic one.
200
+ 6. `/auth/reset-password` loads while signed out.
143
201
 
144
- Preserve existing `@neondatabase/auth/react/ui` imports rather than forcing a drive-by migration. New snippets use `@neondatabase/auth-ui`.
202
+ Leave an existing app on `@neondatabase/auth-ui` alone rather than migrating it as a drive-by. New snippets use Better Auth UI.
145
203
 
146
204
  ## Cross-subdomain vs bearer JWT
147
205
 
@@ -170,4 +228,4 @@ export default defineConfig({
170
228
  });
171
229
  ```
172
230
 
173
- Do not enable Auth merely to satisfy a `dataApi` type error in an app that never needed the Data API. External JWKS on a Claimable project is accepted only after claim. Combined SDK `createClient({ dataApi: { url, getToken } })` is a query client without `.auth`; confirm the installed `@neondatabase/neon-js` docs before introducing it.
231
+ Do not enable Auth merely to satisfy a `dataApi` type error in an app that never needed the Data API. External JWKS on a Claimable project is accepted only after claim. Combined SDK `createClient({ dataApi: { url, getToken } })` is a query client without `.auth`; confirm the installed `@neon/neon-js` docs before introducing it.