prisma-express-admin
v0.5.5
Published
A Django-like admin panel for Express and Prisma, with optional built-in admin authentication
Maintainers
Readme
Prisma Express Admin
Rebranded as PanelJS. New work lives at
paneljs(paneljs,@paneljs/express,@paneljs/prisma). This package remains as a compatibility name; prefer PanelJS for new projects.
A Django-admin-like admin panel for Express and Prisma. It introspects your Prisma schema, exposes protected scalar CRUD routes, and serves a schema-driven operations UI.
Requirements
- Node.js
^20.19 || ^22.12 || >=24.0(or Bun>=1.3) - Express 4 or 5
- Prisma and
@prisma/client7.5.x - Your application's generated Prisma client and
schema.prisma
The first release supports Prisma 7.5.x only. Prisma internals are version
coupled, so keep prisma, @prisma/client, and Prisma Express Admin in that
same supported range. Upgrade them together after a supported version is
announced; the changelog records every tested Prisma version.
Install
npm install prisma-express-admin express @prisma/client
npm install --save-dev prismaGenerate your Prisma client as usual, then pass that client to the admin. The library never uses a client generated by this repository.
Use
import express from "express";
import { createAdmin } from "prisma-express-admin";
import { prisma } from "./prisma.js";
const app = express();
const admin = createAdmin({
prisma,
auth: {
getCurrentUser: async (req) => {
// Adapt this to your session, JWT, or API-key authentication.
const user = await getAdminUserFromRequest(req);
return user
? {
id: user.id,
email: user.email,
role: user.role,
isSuperAdmin: user.isSuperAdmin,
}
: null;
},
},
});
admin
.register("User")
.register("Post", { listDisplay: ["title", "published", "createdAt"] });
await admin.mount(app);
app.listen(3000);Open http://localhost:3000/admin. Every admin API request requires either
the configured external adapter or built-in admin authentication. Built-in mode
provides /admin/login, database-backed admin sessions, and a
createsuperuser command. See the authentication guide.
Schema file
At mount time, Prisma Express Admin reads prisma/schema.prisma relative to
your application's current working directory. Include that schema file in your
deployment artifact. If your schema is elsewhere, configure it explicitly:
const admin = createAdmin({
prisma,
schemaPath: "db/schema.prisma",
auth: { getCurrentUser },
});Current scope
This MVP provides authenticated, permission-aware, tenant-scoped scalar CRUD,
search, filters, pagination, relation display fields in lists, safe
single-field foreign-key selection for belongsTo relations in create/edit
forms, and permission/scoped custom actions on selected list records. Audit
logging is available through an optional consumer-provided append-only writer.
Nested writes, many-to-many editing, and file uploads are not available yet.
See the docs site and the
HTTP API reference for the complete route and
validation contract.
Documentation
The consumer docs site lives in docs/ and is built with VitePress.
bun run docs:devOpen the printed localhost URL. Start at Getting started, then Wire it into your app.
Developing this repository
The library source is in src/. The runnable dogfood application is fully
self-contained in examples/basic/, including its schema,
local PostgreSQL service, generated client, and sample data.
bun install
bun run example:db:up
export DATABASE_URL=postgresql://postgres:postgres@localhost:5435/prisma_express_admin_basic
bun run example:db:generate
bun run example:db:push
bun run example:seed
bun run devOpen http://localhost:3000/admin to use the local example. Its authentication
adapter is intentionally development-only; see the
example README for the complete walkthrough.
Useful checks:
bun run typecheck
bun run test:unit
bun run build
bun run docs:dev
npm pack --dry-runAfter starting PostgreSQL and running bun run db:push, run
bun run test:integration for the database-backed scope suite.
Marketing landing page
Preview the product landing page with bun run landing, then open
http://localhost:4173.
