Skip to content

Getting Started

fastify-admin is an npm package that plugs into any existing Fastify + MikroORM app. It auto-discovers your entities and generates a full CRUD admin UI with authentication, RBAC, and dark mode — no frontend code required.


Install

Terminal window
npm install fastify-admin

Zero Config

Pass your MikroORM instance to the plugin. That’s it.

import Fastify from 'fastify'
import { MikroORM } from '@mikro-orm/postgresql'
import { fastifyAdmin } from 'fastify-admin'
import config from './mikro-orm.config.js'
const orm = await MikroORM.init(config)
const app = Fastify()
await app.register(fastifyAdmin, { orm })
await app.listen({ port: 3001 })
// Admin UI → http://localhost:3001

All your MikroORM entities are auto-discovered. The plugin generates a full list/view/create/edit/delete UI for each one, serves the bundled frontend at /, and registers all API routes under /api/.


Create Your First Admin User

Terminal window
npx fastify-admin create-admin

Follow the prompts. The user is automatically given the Admin role.


What You Get for Free

FeatureDetails
Auto CRUDList, view, create, edit, delete for every entity
AuthenticationEmail/password login, sessions, JWT
RBACAdmin and Viewer roles out of the box, fully manageable
Dark modeLight / dark / system toggle built in
RelationsManyToOne, ManyToMany rendered as dropdowns automatically
Security sectionUser, Role, Permission management hidden from main nav

On first start the plugin automatically runs migrations and seeds the Admin/Viewer roles.


Full Developer Control

Everything is opt-in — start zero-config and add customisation only where you need it.

Customise an entity

await app.register(fastifyAdmin, {
orm,
views: {
post: {
label: 'Blog Posts',
icon: 'BookOpen01',
list: { columns: ['id', 'title', 'published'] },
edit: { fields: ['title', 'content', 'published'] },
},
},
})
import { EntityView, ViewRegistry } from 'fastify-admin'
class PostView extends EntityView {
label = 'Blog Posts'
icon = 'BookOpen01'
listColumns() { return ['id', 'title', 'published'] }
editFields() { return ['title', 'content', 'published'] }
permissions() {
return { delete: false } // disable delete for all users
}
}
const views = new ViewRegistry()
.register('post', new PostView())
await app.register(fastifyAdmin, { orm, views })

Plugin options

OptionTypeDefaultDescription
ormMikroORMrequiredYour initialised MikroORM instance
namestring'Fastify Admin'Panel name shown in the sidebar
viewsRecord<string, EntityView | EntityConfig> | ViewRegistry{}Per-entity customisation
signupbooleanfalseAllow self-registration
requireEmailVerificationbooleanfalseRequire email OTP on signup
mfaEnabledbooleanfalseEnable MFA (requires SMTP)
securityEntitiesstring[]['user','role','permission']Entities hidden from main nav
appBaseUrlstring'http://localhost:3001'Base URL for OAuth callbacks

All options can also be set via environment variables — see Configuration.


Next Steps