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.
- NestJS 10
- AdminJS 7
- Mongoose 7
- 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
.nvmrcwith20or runnvm use 20so the correct runtime is selected automatically.
- Clone the repo and install dependencies:
git clone https://github.com/niksbanna/adminjs-nestjs-example-app.git cd adminjs-nestjs-example-app yarn install - Copy the sample environment file and adjust values:
Update
cp .env.example .env
DB_URLto point at your MongoDB instance. - Start the API:
yarn start:dev
- Visit
http://localhost:3000/adminand sign in with the default credentials below.
DB_URL– Mongo connection string consumed byMongooseModule.forRoot
- Email:
admin@example.com - Password:
password
Update DEFAULT_ADMIN in src/app.module.ts if you need different seed credentials.
yarn start– run NestJS in production mode (compiles first if needed)yarn start:dev– start the dev server with file watchingyarn start:prod– run the compiled app fromdistyarn build– compile TypeScript intodistyarn test/yarn test:e2e– execute unit or e2e test suites
- 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.
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.
Participation in this project is governed by the Code of Conduct. Please read it before engaging with the community.
This project is licensed under the MIT License.
- Ensure
mainis green and your working tree is clean. - Bump version and generate changelog with:
yarn release
- Push the tag and updated files:
git push --follow-tags origin main
- Draft release notes on GitHub if desired and publish the tag.