neon-functions

Deploy long-running Node.js HTTP functions onto Neon branches with injected database connections.

Updated Jul 29, 2026
One-click install
npx skills add https://github.com/zomeru/zomlab --skill neon-functions-zomeru
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: neon-functions
Source: https://github.com/zomeru/zomlab/tree/main/.agents/skills/neon-functions
Command: npx skills add https://github.com/zomeru/zomlab --skill neon-functions-zomeru

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @neon/config, @neon/functions, @neon/env, hono, drizzle-orm, pg, and includes references (resource) components.

What problem does it solve? Lambda-style serverless functions time out on long-running workloads like AI agent streams, WebSocket servers, and SSE endpoints. This Skill guides you through deploying long-running Node.js 24 HTTP handlers directly onto a Neon branch, with DATABASE_URL injected automatically and compute running in the same region as your Postgres data. ## Core Features & Use Cases - Long-Running Handlers: Deploy web-standard fetch handlers with a 15-minute time-to-first-byte budget, supporting streaming agents, WebSocket servers, and SSE endpoints that outlast traditional serverless limits. - Branch-Scoped Backends: Each Neon branch runs its own function version at its own URL against its own isolated database, so preview and CI environments get self-contained backends via neon.ts infrastructure-as-code. - Integrated References: Includes in-depth guides for building Vercel AI SDK agents, Mastra agents with observability, MCP servers, SSE endpoints, and Sentry error monitoring on Functions. - Use Case: You have a Next.js app on Vercel whose AI agent stream gets cut off by the host's 60-second limit. Move just the agent onto a Neon Function, mint a short-lived JWT on your backend, and have the browser call the function directly so the stream runs to completion next to your database. ## Quick Start Ask the AI to define a Hono-based function in neon.ts, run neon dev locally, and deploy it with neon deploy to get a public invocation URL.

Frequently Asked Questions about neon-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I deploy a long-running serverless function next to my Neon database?▼

Declare the function under preview.functions in a neon.ts file with a slug and source entry file, then run neon deploy to bundle it with esbuild and apply it to the linked branch. Retrieve the public invocation URL with neon functions get <slug>.

How do I run an AI agent without serverless timeouts?▼

Host the agent as a Neon Function, which allows up to 15 minutes to first byte and keeps streams alive while bytes flow. Have the browser call the function directly with a short-lived JWT instead of proxying through your web host, which would re-impose its own short execution cap.

Can I run a WebSocket or SSE server on Neon Functions?▼

Yes. Use upgradeWebSocket from @neon/functions for WebSockets, or return a Response with a ReadableStream body and Content-Type text/event-stream for SSE. Connections stay alive as long as bytes flow, so send a heartbeat roughly every 25-30 seconds.

Does Neon Functions work on existing Neon projects or other regions?▼

No. Neon Functions is a public beta available only on new projects in the us-east-2 region and cannot be enabled on existing projects. Functions usage is not billed during the beta.

Why do my WebSocket clients miss messages in production but not locally?▼

Under load the runtime runs several isolates in parallel, each with its own module state, so in-process broadcast only reaches clients on the same isolate. Use Postgres as the shared source of truth with polling or LISTEN/NOTIFY so every isolate pushes events to its own clients.

Should I use the Neon serverless driver or node-postgres in a function?▼

Use node-postgres (pg) with an ORM like Drizzle, creating one pool at module scope with a small max such as 5. Functions reuse isolates across many requests, so a persistent pool amortizes connection setup, unlike the serverless driver designed for isolated lambda runtimes.