Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vercel/postgres

Package Overview
Dependencies
Maintainers
216
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/postgres

Connect to Vercel Postgres databases on the Edge.

  • 0.1.0-canary.3
  • bundling
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
43K
decreased by-39.17%
Maintainers
216
Weekly downloads
 
Created
Source

@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']);

Connection Config

When using the createClient function, you can pass an optional configuration object that conforms to PostgresConfig:

export interface PostgresConfig {
  connectionString?: string | undefined;
  keepAlive?: boolean | undefined;
  statement_timeout?: false | number | undefined;
  query_timeout?: number | undefined;
  keepAliveInitialDelayMillis?: number | undefined;
  idle_in_transaction_session_timeout?: number | undefined;
  application_name?: string | undefined;
  connectionTimeoutMillis?: number | undefined;
  max?: number | undefined;
  min?: number | undefined;
  idleTimeoutMillis?: number | undefined;
  log?: ((...messages: unknown[]) => void) | undefined;
  allowExitOnIdle?: boolean | undefined;
  maxUses?: number | undefined;
}

Documentation

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

FAQs

Package last updated on 14 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc