Getting Started
Quick Start
No installation needed! Just run this command:
npx db-studioThis runs the latest version of DB Studio using your current folder as the project location.
How It Works
DB Studio looks for your database connection in this order:
- Checks for a
.envfile in your current folder - If not found, searches parent folders until it finds one
- Reads
DATABASE_URLfrom that file - If
DATABASE_URLisn't in the file, checks your system environment variables
Setting Up Your Database Connection
Create a .env file in your project:
# .env
DATABASE_URL=postgresql://user:password@localhost:5432/mydatabaseThen run:
npx db-studioDB Studio will:
- Find and read your
.envfile - Start a server on port
3333 - Open your browser to
http://localhost:3333
Command Options
You can customize how DB Studio runs with these options:
| Option | What It Does | Example |
|---|---|---|
--env <path> | Use a specific .env file | npx db-studio --env .env.local |
--var-name <name> | Use a different variable name instead of DATABASE_URL | npx db-studio --var-name MY_DB_URL |
--port <number> | Change the server port (default is 3333) | npx db-studio --port 4000 |
--database-url <url> | Provide connection string directly without .env file | npx db-studio --database-url "postgresql://user:pass@localhost:5432/mydb" |
--status | Only check if connection works (doesn't open the UI) | npx db-studio --status |
--help | Show all available options | npx db-studio --help |
Real Examples
# Use a different env file for local development
npx db-studio --env .env.local
# Use production env file with custom port
npx db-studio --env .env.production --port 4444
# Connect directly without env file (good for quick tests)
npx db-studio --database-url "postgresql://user:pass@host:5432/prod"
# Use custom variable name with specific env file
npx db-studio --env .env.staging --var-name STAGING_DB_URL
# Just check if your connection works
npx db-studio --statusAdd to Your Project
You can add DB Studio to your package.json scripts:
{
"scripts": {
"db:studio": "npx db-studio"
}
}Then run it with:
npm run db:studioPassing Options Through npm/bun
When using npm run or bun run, add -- before your options:
# Local dev with custom env file
npm run db:studio -- --env .env.local
# Production with custom port
bun run db:studio -- --env .env.production --port 4444
# Custom variable name
npm run db:studio -- --var-name STAGING_DB_URLSwitching from Other Tools
From Prisma Studio
Replace this:
"scripts": {
"studio": "npx prisma studio"
}With this:
"scripts": {
"studio": "npx db-studio"
}DB Studio uses the same DATABASE_URL from your .env file. No extra config needed!
From Drizzle Studio
Replace this:
"scripts": {
"studio": "npx drizzle-kit studio"
}With this:
"scripts": {
"studio": "npx db-studio"
}Works the same way - just uses your existing DATABASE_URL.