Home

Awesome

@neondatabase/serverless example: query Neon PostgreSQL from a Cloudflare Worker

This repo provides an example of using Neon's @neondatabase/serverless driver package to query PostgreSQL from a Cloudflare Worker, and to cache the results.

The app

The example is a web app that returns a list of your nearest UNESCO World Heritage Sites.

Please note that the UNESCO data is copyright © 1992 – 2022 <a href="https://whc.unesco.org">UNESCO/World Heritage Centre</a>. All rights reserved.

The driver

Neon's @neondatabase/serverless driver is based on and offers the same API as the node-postgres package, which is what you get with npm install pg.

We've simply shimmed the Node libraries it requires, and replaced net.Socket and tls.connect with implementations that encrypt and transfer the data over WebSockets.

Find out more about the driver from the @neondatabase/serverless README on npmjs.com or GitHub.

How to run

To run this app locally:

Feedback and support

Please visit Neon Community or Support.