{"id":22752,"library":"vite-plugin-neon-new","title":"vite-plugin-neon-new","description":"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.","status":"active","version":"0.8.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","neon","database","postgres","vite","neon-new","typescript"],"install":[{"cmd":"npm install vite-plugin-neon-new","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-neon-new","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-neon-new","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency – required as host plugin","package":"vite","optional":false}],"imports":[{"note":"Named export, not default. ESM only.","wrong":"import postgres from 'vite-plugin-neon-new'","symbol":"postgres","correct":"import { postgres } from 'vite-plugin-neon-new'"},{"note":"CJS require returns the module, but the export is named. Use destructuring or require('vite-plugin-neon-new').postgres.","wrong":"const postgres = require('vite-plugin-neon-new')","symbol":"vite-plugin-neon-new","correct":"import { postgres } from 'vite-plugin-neon-new'"},{"note":"PostgresOptions is a TypeScript type, not a runtime value. Use `import type` for type-only imports.","wrong":"import { PostgresOptions } from 'vite-plugin-neon-new'","symbol":"PostgresOptions","correct":"import type { PostgresOptions } from 'vite-plugin-neon-new'"}],"quickstart":{"code":"import { postgres } from 'vite-plugin-neon-new';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [\n    postgres({\n      referrer: 'github:myuser/myrepo',\n    }),\n  ],\n});","lang":"typescript","description":"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."},"warnings":[{"fix":"Add `referrer: 'your-app-name'` to the plugin options.","message":"The `referrer` option is now required as of v3.0.0. Omitting it causes the plugin to throw an error.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace all imports and package.json references from `vite-plugin-db` to `vite-plugin-neon-new`.","message":"Package previously named `vite-plugin-db` is deprecated. Old package will receive no further updates.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use a persistent database provider in production; the plugin is only for development.","message":"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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pass `env: '.env.local'` or your desired path in plugin options.","message":"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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add `.env` to `.gitignore` and use environment-specific env files. Alternatively, use a secrets manager.","message":"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.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add `referrer: 'your-app-name'` to the `postgres()` options object.","cause":"Missing `referrer` option in plugin configuration (required since v3.0.0).","error":"Error: The `referrer` option is required. Please provide a referrer string to use vite-plugin-neon-new."},{"fix":"Use `const { postgres } = require('vite-plugin-neon-new');` or switch to ESM `import { postgres } from 'vite-plugin-neon-new'`.","cause":"Using `require('vite-plugin-neon-new')` without destructuring. The module's default export is undefined; `postgres` is a named export.","error":"TypeError: Cannot destructure property 'postgres' of '...' as it is undefined."},{"fix":"Change to `import type { PostgresOptions } from 'vite-plugin-neon-new'`.","cause":"Attempting to import a TypeScript type as a value with `import { PostgresOptions }` instead of `import type`.","error":"Module '\"vite-plugin-neon-new\"' has no exported member 'PostgresOptions'. Did you mean to use 'import PostgresOptions from \"vite-plugin-neon-new\"' instead?"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}