prisma-pad
v0.2.1
Published
Prisma Pad is a local, read-only data viewer for Prisma apps. Run it from an existing project with `npx`, point it at a Prisma application, and it opens a browser UI for inspecting models, rows, records, and supported Prisma Client read queries.
Readme
Prisma Pad
Prisma Pad is a local, read-only data viewer for Prisma apps. Run it from an existing project with npx, point it at a Prisma application, and it opens a browser UI for inspecting models, rows, records, and supported Prisma Client read queries.
It uses the target app's own prisma, generated @prisma/client, and environment files, so the viewer runs against the same local development setup your app already uses.
Features
- Browse Prisma models and table rows in a local web UI.
- Inspect individual records as fields or JSON.
- Filter, sort, and paginate model rows.
- Run supported read-only Query Lab operations:
findMany,findFirst,findUnique, andcount. - Load database configuration from the target app's Prisma datasource env var.
- Start on an open local port and open your browser automatically.
Requirements
- Node.js 20 or newer
- npm
- A Prisma app with:
prismainstalled@prisma/clientinstalled- a generated Prisma Client
- the datasource env var referenced by your Prisma schema, such as
DATABASE_URLorPOSTGRES_URL, available in an env file or your shell - a reachable development database
Quick Start
From the Prisma app you want to inspect:
npx prisma-pad@latestPrisma Pad starts a local server, prints the URL, and opens the viewer in your default browser.
Prisma Pad running at http://127.0.0.1:54321/
App root: /path/to/your/app
Loaded env: .env.local, .envInstallation
You do not need to install Prisma Pad to use it. The recommended workflow is:
npx prisma-pad@latestIf you use Prisma Pad often, install it globally:
npm install -g prisma-padThen run it from any Prisma app:
prisma-padTo update a global install:
npm update -g prisma-padSet Up Your Prisma App
Prisma Pad runs against an existing Prisma app. In that app, install Prisma and Prisma Client if they are not already installed:
npm install prisma @prisma/clientGenerate Prisma Client:
npx prisma generateMake sure the database URL env var referenced by your Prisma schema is available. Prisma Pad does not require the variable to be named DATABASE_URL; it lets the generated Prisma Client resolve whatever your schema uses.
datasource db {
provider = "postgresql"
url = env("POSTGRES_URL")
}For that schema, define POSTGRES_URL:
POSTGRES_URL="postgresql://user:password@localhost:5432/my_app"The default Prisma name works too:
DATABASE_URL="file:./dev.db"You can place that variable in .env.local, .env, a custom env file, or export it in your shell:
export POSTGRES_URL="postgresql://user:password@localhost:5432/my_app"Environment precedence is:
- the file passed with
--env-file .env.local.env- shell environment
When more than one source defines the same variable, the earlier source in that list wins.
If your app uses another file name, pass it explicitly:
npx prisma-pad@latest --env-file .env.dev.localRelative --env-file paths are resolved from the target app root.
Usage
Run against the current directory:
npx prisma-pad@latestRun against another Prisma app:
npx prisma-pad@latest --root ../my-prisma-appYou can also pass the app root as the first positional argument:
npx prisma-pad@latest ../my-prisma-appUse a fixed port:
npx prisma-pad@latest --port 5174Use a custom env file:
npx prisma-pad@latest --env-file .env.dev.localPrint the URL without opening a browser:
npx prisma-pad@latest --no-openBind to a different host:
npx prisma-pad@latest --host 0.0.0.0 --port 5174CLI Reference
prisma-pad [app-root] [--root <path>] [--env-file <path>] [--host <host>] [--port <port>] [--open] [--no-open]Arguments
| Argument | Description |
| --- | --- |
| app-root | Target Prisma app directory. Defaults to the current working directory. |
Options
| Option | Description |
| --- | --- |
| --root <path> | Target Prisma app directory. Overrides the positional app-root value. |
| --env-file <path> | Additional env file to load. Relative paths resolve from the target app root and override .env.local and .env. |
| --host <host> | Host for the local viewer server. Defaults to 127.0.0.1. |
| --port <port> | Port for the local viewer server. Defaults to an available random port. |
| --open | Open the viewer in the default browser. Enabled by default. |
| --no-open | Print the viewer URL without opening a browser. |
| -h, --help | Show CLI help. |
Safety
Prisma Pad is designed for local development. It exposes read-only API endpoints and does not create, update, delete, run raw SQL, apply migrations, or edit schema files.
Use it with development databases. Do not expose the local viewer server to untrusted networks.
Troubleshooting
Datasource env var is missing
If Prisma Pad reports that your Prisma schema expects an env var, add that exact variable to the target app's .env.local, .env, custom env file, or export it before starting Prisma Pad.
For example, this datasource:
datasource db {
provider = "postgresql"
url = env("POSTGRES_URL")
}needs:
export POSTGRES_URL="postgresql://user:password@localhost:5432/my_app"
npx prisma-pad@latestFor a schema that uses env("DATABASE_URL"):
export DATABASE_URL="postgresql://user:password@localhost:5432/my_app"
npx prisma-pad@latestFor custom env file names:
npx prisma-pad@latest --env-file .env.dev.localPrisma is not installed
Install Prisma in the target app:
npm install prismaPrisma Client is not installed
Install Prisma Client in the target app:
npm install @prisma/clientThe generated Prisma Client is missing
Generate Prisma Client in the target app:
npx prisma generateRows fail to load
Check that your Prisma datasource URL points to a reachable development database and that the database schema matches the generated Prisma Client. If you changed schema.prisma, run:
npx prisma generateDevelopment
Install dependencies:
npm installRun the frontend Vite dev server:
npm run devBuild the frontend and Node CLI:
npm run buildRun tests:
npm testHow It Works
- The CLI resolves the target app root.
- It loads environment files from the target app.
- It verifies
prismaand@prisma/client. - It initializes the target app's generated Prisma Client, letting Prisma resolve the datasource env var from the schema.
- It starts a local Vite server with Prisma Pad API middleware.
- It opens the browser to the local viewer unless
--no-openis passed.
