---
title: "How to use Postgres at the Edge"
description: "Standard Postgres can't be reached from V8-isolate edge runtimes like Vercel Edge Functions because they don't support raw TCP."
url: "https://swe.quest/articles/how-to-use-postgres-at-the-edge-9d5045c1101b2176"
canonical: "https://neon.com/blog/how-to-use-postgres-at-the-edge"
source: "Neon"
published: "2023-09-19"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["postgres","serverless","cdn-edge","javascript"]
---

# How to use Postgres at the Edge

A post on [Neon](https://swe.quest/sources/neon.md), published 2023-09-19, 4 min read, How-to. Original: [https://neon.com/blog/how-to-use-postgres-at-the-edge](https://neon.com/blog/how-to-use-postgres-at-the-edge)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [CDN & edge](https://swe.quest/tags/cdn-edge.md) (Infrastructure)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- Next.js API routes ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- basic SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- serverless functions ([easy posts on Serverless](https://swe.quest/tags/serverless.md?difficulty=easy))

## Keywords

Neon, Vercel Edge Functions, Next.js, @neondatabase/serverless, node-postgres, WebSockets, V8 isolates

## Related posts

- [Sub-10ms Postgres queries for Vercel Edge Functions](https://swe.quest/articles/sub-10ms-postgres-queries-for-vercel-edge-functions-6bc9caef6fab65ca.md): Neon · 2023-07-10 · Medium · 3 min read · PostgreSQL, Serverless, CDN & edge, Performance engineering, TypeScript
  Neon's serverless Postgres driver now supports SQL-over-HTTP via fetch, and Neon's proxy adds opt-in experimental connection caching (\`fetchConnectionCache\`).
- [Edge-compatible Serverless Driver for Postgres](https://swe.quest/articles/edge-compatible-serverless-driver-for-postgres-9b0d09c6c7a067d0.md): Neon · 2022-12-08 · Medium · 9 min read · PostgreSQL, Serverless, Networking, Cryptography, WebAssembly
  Neon's @neondatabase/serverless driver lets V8-isolate platforms like Cloudflare Workers, which lack TCP, speak the real Postgres wire protocol by tunnelling it over a WebSocket to an open-source Go proxy that relays to TCP.
- [Neon Functions: backend logic next to your data](https://swe.quest/articles/neon-functions-backend-logic-next-to-your-data-fe00336dce0040ff.md): Neon · 2026-08-12 · Medium · 5 min read · Serverless, PostgreSQL, Real-time systems
  Neon Functions are long-running Node.js 24 compute deployed onto a Neon branch, in the same region and on the same infrastructure as its Lakebase Postgres database, with DATABASE\_URL and other Neon backend credentials injected automatically.
- [Web-based AI SQL Playground and connecting to Postgres from the browser](https://swe.quest/articles/web-based-ai-sql-playground-and-connecting-to-postgres-from-the-browser-fa7f4eccd9643a37.md): Neon · 2023-05-19 · Medium · 5 min read · PostgreSQL, LLMs, Serverless, JavaScript
  Neon's Postgres AI Playground connects to a Postgres database directly from the browser and uses OpenAI's gpt-3.5-turbo to turn natural-language prompts into SQL.
- [@neondatabase/serverless hits 1.0.0](https://swe.quest/articles/neondatabase-serverless-hits-1-0-0-d5430675bc92b751.md): Neon · 2025-03-25 · Medium · 5 min read · PostgreSQL, Serverless, TypeScript, Application security, JavaScript
  Neon's JavaScript/TypeScript serverless driver, which carries Postgres queries over HTTP and WebSockets for environments without raw TCP such as V8 isolates and browsers, reaches 1.0.0 after a refactor that adds auto-generated types via api-extractor and CI tests across Node, Bun, Deno, browsers, Cloudflare Workers, Vercel and the Prisma/Drizzle adapters.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
