Hype StackHypeStack

Admin app

The SaaS starters ship a separate admin app into your monorepo at apps/admin. It's a third surface next to apps/frontend and apps/backend, built for operators (you and your team), not your end users. Both starters ship the same admin, so you get it whether you pick WorkOS or Better Auth.

What's inside

The admin app has its own login and a set of private, role-gated screens:

ScreenRouteWho can open it
Dashboard/Any admin
Users/users, /users/$userIdAny admin
Organizations/orgs, /orgs/$organizationIdAny admin
Settings/settingsSuper admin only
Login/loginPublic

On the backend, the starter adds /admin API routes (dashboard stats, users, orgs) and /admins/* for super-admin CRUD of admin records. An admin Prisma model stores who has access beyond the bootstrap list.

How super-admin auth works

Admin access uses an AdminRole (super_admin or admin). Resolution order:

  1. SUPER_ADMIN_EMAIL - comma-separated emails. Matching sign-ins are always super_admin, even with no row in the admin table. This is how you get the first operator in.
  2. admin table - super admins add and manage these from the Settings screen. Middleware is withAdmin / withSuperAdmin on top of the same identity provider as the customer app.

Helpers live under apps/backend/src/features/admin/helpers/super-admin.ts and apps/backend/src/utils/auth/admin-hono.ts (getAdminApp()).

Set the bootstrap list in apps/backend/.env:

bash
SUPER_ADMIN_EMAIL=you@example.com,teammate@example.com

How feature packs extend the admin

Feature packs do not ship a second admin app. They plug into this one through pack manifests and codemods:

Extension pointWhat packs do
Nav slot adminAdds sidebar entries (for example Notifications)
Dashboard rowsInjects metric cards into the dashboard
Extra routes / featuresAdds API routes and admin UI modules under apps/admin and apps/backend
Org detail cardsComposes billing or license cards onto organization pages

Examples:

  • Billing (Stripe) adds a revenue row on the dashboard, org billing cards, and /admin/billing API routes.
  • Notifications adds a Notifications nav entry and admin send UI.

Install any of these on top of a starter and the widgets and routes show up automatically after the CLI finishes.

Where to add your own admin screens

  1. Add a route under apps/admin/src/routes/(private)/...
  2. Add backend routes under apps/backend/src/routes/admin-... mounted with getAdminApp() (or withSuperAdmin when only super admins should call them)
  3. Gate UI with the same admin role checks the starter already uses
  4. Prefer composing into the dashboard or org detail pages when the feature is a metric or a card, not a whole section

Running it

bash
pnpm dev

Nx starts frontend, backend, and admin with hot reload. Sign in with a SUPER_ADMIN_EMAIL account.

Environment variables

VariablePurpose
SUPER_ADMIN_EMAILComma-separated bootstrap super admin emails. Optional but you need at least one to sign in the first time.
Sponsor open source

Every purchase and sponsorship funds my 8+ years of work on open source given freely to the community. It keeps the lights on, funds new packs, and keeps the ecosystem alive. Even a small tier means a lot. Thank you!

Sponsor on GitHub