pg-here
v0.1.9
Published
Per-project embedded PostgreSQL with programmatic startup and auto DB creation.
Downloads
1,750
Maintainers
Readme
pg-here
Run a local PostgreSQL instance in your project folder with one command.
30-second start
bunx pg-hereDefault output:
Launching PostgreSQL 18.0.0 into new pg_local/
psql postgresql://postgres:postgres@localhost:55432/postgresIf a data folder already exists:
Reusing existing pg_local/data/ with PostgreSQL 18.0.0
psql postgresql://postgres:postgres@localhost:55432/postgresIf the cached folder version differs:
Reusing existing pg_local/data/ (pg_local/bin has 18.0.0, running PostgreSQL is 18.0)
psql postgresql://postgres:postgres@localhost:55432/postgresThe process stays alive until you stop it.
Ctrl+C → exits and stops Postgres.
Defaults (all args optional)
bunx pg-here
username = postgrespassword = postgresdatabase = postgresport = 55432pg-version= auto
Custom run
bunx pg-here --username me --password secret --database my_app --port 55433 --pg-version 17.0.0You can also run locally in this repo:
bun run db:upSame CLI flags are supported.
Programmatic
import { startPgHere } from "pg-here";
const pg = await startPgHere({
projectDir: process.cwd(),
database: "my_app",
createDatabaseIfMissing: true,
});
console.log(pg.databaseConnectionString); // psql-ready URL
await pg.stop();Linux runtime error (quick fix)
If startup fails with missing libxml2 libraries, install runtime packages and retry:
sudo apt-get update && sudo apt-get install -y libxml2 libxml2-utils
sudo dnf install -y libxml2
sudo apk add libxml2This release already retries startup with a project-local libxml2 compatibility fallback when needed.
Version pin / stale cache
If your environment keeps resolving an older release, force a specific version:
bunx [email protected]