Watch Neon Developer Days #3 🚀

Release notes

The latest product updates from Neon

RSS feed

Neon serverless driver enhancements

The Neon serverless driver is a low-latency Postgres driver for JavaScript and TypeScript that allows you to query data from serverless and edge environments over HTTP or WebSockets in place of TCP.

The driver now supports batched queries and a larger response size for queries over HTTP.

Batched queries

You can now issue multiple queries at once in a single, non-interactive transaction using the transaction() function, which is exposed as property of the query function. For example:

The transaction() function supports the same option keys the ordinary query function — arrayMode, fullResults, and fetchOptions — plus three additional keys for transaction configuration:

  • isolationMode

    Must be one of ReadUncommitted, ReadCommitted, RepeatableRead, or Serializable.

  • readOnly

    Ensures that a READ ONLY transaction is used to execute queries. The default value is false.

  • deferrable

    Ensures that a DEFERRABLE transaction is used to execute queries. The default value is false.

For more information, see transaction(...) function.

Larger response sizes

The maximum response size for queries over HTTP was raised from 1 MB to 10 MB.

Faster Postgres queries for Vercel Edge Functions

The Neon serverless driver now supports for SQL queries over HTTP, providing up to a 40% reduction in query latencies from Vercel Serverless Functions and Edge Functions for one-shot queries. The enhanced driver brings same-region query response times down to single-digit milliseconds.

Additionally, we worked with the team at Drizzle to add Neon serverless driver support for Drizzle-ORM, an ORM for TypeScript. For an example demonstrating how to use the driver with Drizzle-ORM for type safety, see How to use the driver.

Refer to the blog post to learn more: Sub-10ms Postgres queries for Vercel Edge Functions.

Deno support for the Neon serverless driver

The Neon serverless driver was verified to work with Deno. Where you would install another Postgres driver, run npm install @neondatabase/serverless instead, and then import the Neon serverless driver:

Fixes & improvements

  • Released a new version of the Neon serverless driver (v0.2.6), which allows you to query data from Cloudflare Workers, Vercel Edge Functions, and other environments that support WebSockets. The updated driver offers:

    • Automatic import of the ws (WebSocket library) package if required, which makes the driver easier to use on StackBlitz and with Zapatos, for example.
    • More helpful error messages when connection details are not provided. For example, a more informative error message is reported if you forget to set an environment variable for the database connection or forget to include a password in your database connection string.
  • Added three new example application repositories to help you get started with the Neon serverless driver on Vercel Edge Functions. The example application generates a JSON listing of the 10 nearest UNESCO World Heritage sites using IP geolocation (data copyright © 1992 – 2022 UNESCO/World Heritage Centre).

    UNESCO World Heritage sites app

    • The neondatabase/neon-vercel-rawsql example demonstrates using raw SQL with Neon's serverless driver on Vercel Edge Functions.
    • The neondatabase/neon-vercel-zapatos example demonstrates using Zapatos with Neon's serverless driver on Vercel Edge Functions. Zapatos offers zero-abstraction Postgres for TypeScript.
    • The neondatabase/neon-vercel-kysely example demonstrates using kysely and kysely-codegen with Neon's serverless driver on Vercel Edge Functions. Kysely is a type-safe and autocompletion-friendly typescript SQL query builder. kysely-codegen generates Kysely type definitions from your database.

    The UNESCO World Heritage sites example is also available for the Neon serverless driver on Cloudflare Workers. See neondatabase/serverless-cfworker-demo.

Edit this page
Was this page helpful?