Skip to content

niksbanna/adminjs-nestjs-example-app

AdminJS + NestJS Example

This project showcases how to wire up AdminJS inside a NestJS REST API using Mongoose. It includes a ready-to-run admin panel with a sample administrator account and MongoDB-backed resources.

Stack

  • NestJS 10
  • AdminJS 7
  • Mongoose 7

Requirements

  • Node.js 18.x or 20.x (<= 20.* is required – AdminJS 7 uses JSON import assertions that break on Node 21+)
  • Yarn 1.22+
  • Running MongoDB instance (local or hosted)

Tip: add an .nvmrc with 20 or run nvm use 20 so the correct runtime is selected automatically.

Quick Start

  1. Clone the repo and install dependencies:
    git clone https://github.com/niksbanna/adminjs-nestjs-example-app.git
    cd adminjs-nestjs-example-app
    yarn install
  2. Copy the sample environment file and adjust values:
    cp .env.example .env
    Update DB_URL to point at your MongoDB instance.
  3. Start the API:
    yarn start:dev
  4. Visit http://localhost:3000/admin and sign in with the default credentials below.

Environment Variables

  • DB_URL – Mongo connection string consumed by MongooseModule.forRoot

Default Admin Credentials

  • Email: admin@example.com
  • Password: password

Update DEFAULT_ADMIN in src/app.module.ts if you need different seed credentials.

Available Scripts

  • yarn start – run NestJS in production mode (compiles first if needed)
  • yarn start:dev – start the dev server with file watching
  • yarn start:prod – run the compiled app from dist
  • yarn build – compile TypeScript into dist
  • yarn test / yarn test:e2e – execute unit or e2e test suites

Troubleshooting

  • SyntaxError: Unexpected identifier 'assert' – make sure you are using Node 18 or 20. AdminJS 7 has not yet migrated to the new import-attributes syntax required by Node 21+.
  • Verify MongoDB is reachable at the URL provided in .env; NestJS will fail to boot if the database connection is refused.

Contributing

Pull requests are welcome. Please open an issue first if you plan significant changes so we can coordinate the direction. For detailed guidance, review the Contributing Guidelines.

Community Standards

Participation in this project is governed by the Code of Conduct. Please read it before engaging with the community.

License

This project is licensed under the MIT License.

Release Process

  1. Ensure main is green and your working tree is clean.
  2. Bump version and generate changelog with:
    yarn release
  3. Push the tag and updated files:
    git push --follow-tags origin main
  4. Draft release notes on GitHub if desired and publish the tag.