Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 12 min read How-to mediumAdept

Build and Deploy a Global Serverless Nuxt SSR App with Cloudflare Hyperdrive and Postgres

A Nuxt SSR app on Cloudflare Pages can query Neon Postgres through Hyperdrive by routing Drizzle's pg-proxy driver to a separate Hono-based Cloudflare Worker that holds the Hyperdrive binding and runs queries with node-postgres. The detour through a Worker exists because Pages Functions don't fully support node-postgres yet, which breaks local Nuxt builds. The walkthrough covers the nitro cloudflare-pages preset, creating the Hyperdrive config from a pooled Neon connection string, wrangler.toml with node_compat, the Worker's /query endpoint, and the Drizzle proxy driver. Hyperdrive's default cache serves responses for 60 seconds with a 15-second stale-while-revalidate window. The example endpoints are unauthenticated and must be locked down before production use.

Assumes: Nuxt server routesCloudflare Workers and wranglerDrizzle ORMPostgreSQL connection strings

Related posts

  • Build a serverless API using Cloudflare Workers, Drizzle ORM, and Neon

    Neon mediumAdept

    A step-by-step setup for a serverless TypeScript API on Cloudflare Workers that uses Hono for routing, Drizzle ORM for schema definition and migrations, and Neon serverless Postgres for storage. It scaffolds a Worker with create-cloudflare, defines a products table in TypeScript, and uses drizzle-kit to generate SQL migrations. Migrations run through a postgres.js script capped at a single connection so they execute in order. The Worker queries Neon over HTTP via @neondatabase/serverless, is deployed with wrangler, and gets its DATABASE_URL from Cloudflare's Neon integration instead of manually configured secrets.

  • Sub-10ms Postgres queries for Vercel Edge Functions

    Neon mediumAdept

    Neon's serverless Postgres driver now supports SQL-over-HTTP via fetch, and Neon's proxy adds opt-in experimental connection caching (`fetchConnectionCache`). Together they cut query latency from Vercel Serverless and Edge Functions by about 40%, bringing same-region one-shot queries to single-digit milliseconds. Use the `neon` HTTP function for a single query per invocation and `Pool` when a function runs multiple queries. Drizzle-ORM also supports the driver for type-safe queries.

  • Using Hyperdrive with Neon and Cloudflare Workers: FAQ

    Neon mediumAdept

    Cloudflare Hyperdrive is a globally distributed connection pooler and read-query cache for Workers. Because Workers keep warm connections at the nearest edge node, the ~6 round trips of TCP setup, TLS handshake, Postgres auth and query collapse to one. Neon measured roughly 9x faster global SELECT queries with Hyperdrive. Neon's recommendation is to connect Hyperdrive with standard TCP drivers like node-postgres or Postgres.js, and to skip both Neon's PgBouncer pooler and the Neon serverless driver, which uses WebSockets or HTTP and is redundant or incompatible here.

  • How to build a complete Next.js app with Vercel and CockroachDB

    Cockroach Labs mediumAdept

    A step-by-step build of a social events app using Next.js pages, Vercel serverless API routes, and a CockroachDB free-tier cluster accessed via the Node.js pg driver. It covers creating the cluster, the events and people tables, storing the CA certificate and connection string as Vercel environment variables, and wiring a shared pg Pool config into API routes and getServerSideProps. The React-Bootstrap pages add events, list them, collect RSVPs, and show responders per event. The example code builds SQL by string interpolation and acquires pool clients without releasing them, so real apps should use parameterized queries and release connections.

  • How to use Postgres at the Edge

    Neon mediumAdept

    Standard Postgres can't be reached from V8-isolate edge runtimes like Vercel Edge Functions because they don't support raw TCP. Neon's serverless driver, a drop-in replacement for node-postgres, gets around this by talking HTTP or WebSockets to a Neon proxy, which opens the TCP connection to Postgres. The walkthrough shows Next.js edge API routes using the `neon` SQL-over-HTTP function for single-shot queries and `Pool`/`Client` over WebSockets for multiple queries per connection. It then combines `@vercel/edge` geolocation with an INSERT into a locations table, as in the Ping Thing demo.

The quest for software engineering knowledge.

Look:
Layout: