vite-plugin-neon-new
raw JSON → 0.8.0 verified Mon Apr 27 auth: no javascript
Vite plugin that automatically provisions a Neon Postgres database and writes the connection string to your .env file during development. v0.8.0 is the current stable version; released occasionally. Key differentiator: zero-config, claimable databases on first dev server start. Unlike alternatives (e.g., dotenv + manual DB setup), it handles provisioning and teardown automatically. Previously named vite-plugin-db; the old package is deprecated.
Common errors
error Error: The `referrer` option is required. Please provide a referrer string to use vite-plugin-neon-new. ↓
cause Missing `referrer` option in plugin configuration (required since v3.0.0).
fix
Add
referrer: 'your-app-name' to the postgres() options object. error TypeError: Cannot destructure property 'postgres' of '...' as it is undefined. ↓
cause Using `require('vite-plugin-neon-new')` without destructuring. The module's default export is undefined; `postgres` is a named export.
fix
Use
const { postgres } = require('vite-plugin-neon-new'); or switch to ESM import { postgres } from 'vite-plugin-neon-new'. error Module '"vite-plugin-neon-new"' has no exported member 'PostgresOptions'. Did you mean to use 'import PostgresOptions from "vite-plugin-neon-new"' instead? ↓
cause Attempting to import a TypeScript type as a value with `import { PostgresOptions }` instead of `import type`.
fix
Change to
import type { PostgresOptions } from 'vite-plugin-neon-new'. Warnings
breaking The `referrer` option is now required as of v3.0.0. Omitting it causes the plugin to throw an error. ↓
fix Add `referrer: 'your-app-name'` to the plugin options.
deprecated Package previously named `vite-plugin-db` is deprecated. Old package will receive no further updates. ↓
fix Replace all imports and package.json references from `vite-plugin-db` to `vite-plugin-neon-new`.
gotcha The plugin is a noop in production builds (when `NODE_ENV=production` or `vite build`). It will NOT create or connect to a Neon database during production. ↓
fix Use a persistent database provider in production; the plugin is only for development.
gotcha The plugin writes to `.env` file by default. If your project uses `.env.local` (or other env files), you must set the `env` option accordingly to avoid overwriting the wrong file. ↓
fix Pass `env: '.env.local'` or your desired path in plugin options.
gotcha The database connection string is written to a file that may be committed to version control, exposing credentials. Neon databases are claimable and can be reclaimed by others. ↓
fix Add `.env` to `.gitignore` and use environment-specific env files. Alternatively, use a secrets manager.
Install
npm install vite-plugin-neon-new yarn add vite-plugin-neon-new pnpm add vite-plugin-neon-new Imports
- postgres wrong
import postgres from 'vite-plugin-neon-new'correctimport { postgres } from 'vite-plugin-neon-new' - vite-plugin-neon-new wrong
const postgres = require('vite-plugin-neon-new')correctimport { postgres } from 'vite-plugin-neon-new' - PostgresOptions wrong
import { PostgresOptions } from 'vite-plugin-neon-new'correctimport type { PostgresOptions } from 'vite-plugin-neon-new'
Quickstart
import { postgres } from 'vite-plugin-neon-new';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
postgres({
referrer: 'github:myuser/myrepo',
}),
],
});