Registry / database / vite-plugin-neon-new

vite-plugin-neon-new

JSON →
library0.8.0jsnpmunverified

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.

npm install vite-plugin-neon-new
INSTALL
IMPORT
SIG · VITE-PLUGIN-NEON-N
V
vite-plugin-neon-new
databasejavascriptv0.8.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

postgres
import { postgres } from 'vite-plugin-neon-new'
import postgres from 'vite-plugin-neon-new'
Named export, not default. ESM only.
vite-plugin-neon-new
import { postgres } from 'vite-plugin-neon-new'
const postgres = require('vite-plugin-neon-new')
CJS require returns the module, but the export is named. Use destructuring or require('vite-plugin-neon-new').postgres.
PostgresOptions
import type { PostgresOptions } from 'vite-plugin-neon-new'
import { PostgresOptions } from 'vite-plugin-neon-new'
PostgresOptions is a TypeScript type, not a runtime value. Use `import type` for type-only imports.

Minimum Vite config using the postgres plugin with required referrer option. On first dev start, provisions a Neon DB and writes DATABASE_URL to .env.

import { postgres } from 'vite-plugin-neon-new'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [ postgres({ referrer: 'github:myuser/myrepo', }), ], });
Debug
Known issues
breakingThe `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.
affects: >=3.0.0
deprecatedPackage 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`.
affects: >=0.0.0
gotchaThe 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.
affects: >=0.0.0
gotchaThe 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.
affects: >=0.0.0
gotchaThe 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.
affects: >=0.0.0
Errors
Common errors & fixes
Error: The `referrer` option is required. Please provide a referrer string to use vite-plugin-neon-new.
Missing `referrer` option in plugin configuration (required since v3.0.0).
fix
Add `referrer: 'your-app-name'` to the `postgres()` options object.
TypeError: Cannot destructure property 'postgres' of '...' as it is undefined.
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'`.
Module '"vite-plugin-neon-new"' has no exported member 'PostgresOptions'. Did you mean to use 'import PostgresOptions from "vite-plugin-neon-new"' instead?
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'`.
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies
viterequiredPeer dependency – required as host plugin
Agent activity
37 hits · last 30 days
node
30
Meta
1
OpenAI (training)
1
Resources
vite-plugin-neon-new — npm install vite-plugin-neon-new · libregistry