
Security News
TeamPCP Is Systematically Targeting Security Tools Across the OSS Ecosystem
TeamPCP is targeting security tools across the OSS ecosystem, turning scanners and CI pipelines into infostealers to access enterprise secrets.
vite-plugin-db
Advanced tools
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.
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 withvite-plugin-dbin your imports and package.json.
vite dev, the plugin checks for a DATABASE_URL (or your configured key) in your .env..env.npm add vite-plugin-db
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(), react()],
});
You can pass an options object to customize the .env file path, the environment variable name, and database seeding:
postgres({
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_")
seed: {
type: "sql-script",
path: "./schema.sql", // Path to SQL file to execute after database creation
},
});
| Option | Type | Description | Default |
|---|---|---|---|
env | string | Path to the .env file | .env |
envKey | string | Name of the environment variable | DATABASE_URL |
envPrefix | string | Prefix for public environment variables | VITE_ |
seed | object | Configuration for seeding the database | - |
| Property | Type | Description | Default |
|---|---|---|---|
type | string | Type of seeding (currently only "sql-script") | - |
path | string | Path to SQL file to execute after creation | - |
.env.envPrefix (defaults to VITE_ for Vite projects).seed is configured, the specified SQL script will be executed after database creation.interface PostgresPluginOptions {
env: string; // Path to the .env file
envKey: string; // Name of the environment variable
envPrefix: string; // Prefix for public environment variables
seed?: {
type: "sql-script";
path: string;
};
}
DATABASE_URL env var?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.
If you want to generate claimable databases outside of Vite, use the get-db library directly.
See documentation on Neon for more.
FAQs
[DEPRECATED] This package has been renamed to 'vite-plugin-neon-new'. Please use 'vite-plugin-neon-new' instead.
We found that vite-plugin-db demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
TeamPCP is targeting security tools across the OSS ecosystem, turning scanners and CI pipelines into infostealers to access enterprise secrets.

Security News
TypeScript 6.0 introduces new standard APIs, modern default settings, and deprecations as it prepares projects for the upcoming TypeScript 7.0 release.

Security News
/Research
Newly published Trivy Docker images (0.69.4, 0.69.5, and 0.69.6) were found to contain infostealer IOCs and were pushed to Docker Hub without corresponding GitHub releases.