JSPM

  • Created
  • Published
  • Downloads 185376
  • Score
    100M100P100Q53576F
  • License MIT

Connect to Vercel Postgres databases on the Edge.

Package Exports

  • @vercel/postgres

Readme

@vercel/postgres 🚧

A client that works with Vercel Postgres.

Quick Start

Install

npm install @vercel/postgres

Basic Usage

Automatically Read Environment Variables

Default Export

import postgres from '@vercel/postgres';

await postgres.query('SELECT * from POSTS WHERE likes > 100;');

Named Export

import { postgres } from '@vercel/postgres';

await postgres.query('SELECT * from POSTS WHERE likes > 100;');

Set Connection String Manually

import { createClient } from '@vercel/postgres';

const postgres = createClient(process.env.SOME_POSTGRES_CONNECTION_STRING);
await postgres.query('SELECT * from POSTS WHERE likes > 100;');

Parameterized Query

import { postgres } from '@vercel/postgres';

await postgres.query('SELECT * from POSTS WHERE author=$1;', ['rauchg']);

Documentation

The @vercel/postgres package uses pg under the hood. For more detailed documentation, checkout node-postgres.