npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-db

v0.6.1

Published

This Vite plugin instantly provisions a Postgres instance (via Neon) and injects the connection string into your `.env` file, so you can start developing immediately.

Readme

vite-plugin-db

This Vite plugin instantly provisions a Postgres instance (via Neon) and injects the connection string into your .env file, so you can start developing immediately.

Note: This package was previously named @neondatabase/vite-plugin-postgres. The old package is now deprecated. If you're upgrading, simply replace it with vite-plugin-db in your imports and package.json.

How it works

  • On first vite dev, the plugin checks for a DATABASE_URL (or your configured key) in your .env.
  • If not found, it creates a claimable Neon database and writes the connection string to your .env.
  • The plugin is a noop in production builds.

Installation

| Package Manager | Command | | --------------- | -------------------------------- | | npm | npm add -D vite-plugin-db | | pnpm | pnpm add -D vite-plugin-db | | yarn | yarn add -D vite-plugin-db | | bun | bun add -D vite-plugin-db | | deno | deno add -D npm:vite-plugin-db |

Usage

⚠️ BREAKING CHANGE in v3.0.0: The referrer option is now required.

Add the plugin as the first entry in your Vite config:

import { postgres } from "vite-plugin-db";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
	plugins: [
		postgres({
			referrer: "github:username/repo-name", // REQUIRED
		}),
		react(),
	],
});

Configuration

You can pass an options object to customize the .env file path, the environment variable name, and database seeding:

postgres({
	referrer: "your-app-name", // REQUIRED - for tracking and affiliates
	env: ".env.local", // Path to your .env file (default: ".env")
	envKey: "DATABASE_URL", // Name of the env variable (default: "DATABASE_URL")
	envPrefix: "VITE_", // Prefix for public env vars (default: "VITE_")
	settings: {
		logicalReplication: false, // Enable logical replication (default: false)
	},
	seed: {
		type: "sql-script",
		path: "./schema.sql", // Path to SQL file to execute after database creation
	},
});

| Option | Type | Description | Required | Default | | ----------- | ------ | --------------------------------------- | -------- | -------------- | | referrer | string | Referrer identifier for tracking | ✅ Yes | - | | env | string | Path to the .env file | No | .env | | envKey | string | Name of the environment variable | No | DATABASE_URL | | envPrefix | string | Prefix for public environment variables | No | VITE_ | | settings | object | Database configuration settings | No | - | | seed | object | Configuration for seeding the database | No | - |

settings Options

| Property | Type | Description | Default | | ------------------- | ------- | -------------------------- | ------- | | logicalReplication| boolean | Enable logical replication | false |

seed Options

| Property | Type | Description | Default | | -------- | ------ | ----------------------------------------------- | ------- | | type | string | Type of seeding (currently only "sql-script") | - | | path | string | Path to SQL file to execute after creation | - |

What gets written

The plugin writes the following environment variables to your .env:

| Variable | Description | | -------------------------------- | -------------------------------------------------------- | | DATABASE_URL | The pooler connection string (default connection) | | DATABASE_URL_DIRECT | The direct connection string | | {envPrefix}INSTAGRES_CLAIM_URL | Claim URL (valid for 7 days) to take ownership of the DB |

Note: The pooler connection is now the default for DATABASE_URL (as of the latest version). The pooler provides connection pooling and is recommended for most use cases, especially serverless environments.

If seed is configured, the specified SQL script will be executed after database creation.

Type Definitions

interface PostgresPluginOptions {
	referrer: string; // Required - Referrer identifier for tracking
	env?: string; // Path to the .env file
	envKey?: string; // Name of the environment variable
	envPrefix?: string; // Prefix for public environment variables
	settings?: {
		logicalReplication?: boolean; // Enable logical replication (default: false)
	};
	seed?: {
		type: "sql-script";
		path: string;
	};
}

FAQ

The plugin will not overwrite it. Remove the variable if you want to generate a new Neon database.

The plugin is a noop in production mode (vite build), so it won't create databases or modify your .env in CI.

Yes, this plugin is framework-agnostic. The example uses React, but you can use it with any Vite-compatible framework.

Advanced

If you want to generate claimable databases outside of Vite, use the get-db library directly.

See documentation on Neon for more.