get-db
v0.11.0
Published
create a claimable Neon database in seconds!
Readme
Note: This package was previously named
neondb. The old package is now deprecated. If you're upgrading fromneondb, simply replace it withget-dbin your commands and imports.
Usage
npx get-dbCLI Usage
npx get-db [options]Options:
-y, --yesUse defaults, skip prompts-e, --envPath to .env file (default: ./.env)-k, --keyEnv key for connection string (default: DATABASE_URL)-p, --prefixPrefix for public env vars (default: PUBLIC_)-s, --seedPath to SQL file to execute after database creation-h, --helpShow help
SDK/API Usage
Import the SDK:
import { instantNeon } from "get-db/sdk";Create a claimable Neon Postgres database and save credentials to your .env:
await instantNeon({
dotEnvFile: ".env",
dotEnvKey: "DATABASE_URL",
envPrefix: "PUBLIC_",
// This below is to help us understand where usage comes from.
// If you're publishing a library, we'd love that you re-expose a
// referrer parameter in your lib and set this to `npm:your-lib-package-name|${referrer}`
// So we can understand the chain better and give you all the credit you deserve!
referrer: "npm:your-cli-package-name",
});| Option | Default | Description | Validation |
| ---------- | -------------- | ---------------------------------- | --------------------- |
| dotEnvFile | ".env" | Path to env file | letters and . |
| dotEnvKey | "DATABASE_URL" | Environment variable name | `SCREAMING_SNAKE_CASE |
| envPrefix | "PUBLIC_" | Prefix for public environment vars | - |
| referrer | "unknown" | Referrer identifier | - |
Note: The Vite plugin uses
VITE_as the defaultenvPrefixto match Vite's convention for client-side environment variables.
Returns:
| Property | Description |
| ---------------- | ------------------------ |
| databaseUrl | connection string |
| poolerUrl | pooled connection string |
| claimUrl | claim link |
| claimExpiresAt | expiration date |
Environment Variables Written
When you run get-db, the following environment variables are written to your .env file:
| Variable | Description |
| ---------------------------------- | ---------------------------------------------------------- |
| DATABASE_URL | The pooler connection string (default connection) |
| DATABASE_URL_DIRECT | The direct connection string |
| {envPrefix}INSTAGRES_CLAIM_URL | Claim URL (valid for 7 days) to take ownership of the DB |
Note: The pooler connection is now the default for
DATABASE_URL(as of the latest version). The pooler provides connection pooling and is recommended for most use cases, especially serverless environments.
Types
// Params for instantNeon
interface InstantNeonParams {
dotEnvFile?: string;
dotEnvKey?: string;
envPrefix?: string;
referrer?: string;
}See documentation on Neon for more.
This package was templated with create-typescript-app using the Bingo engine.
