Nest
@adminjs/nestjs
AdminJS is now ESM-only. If you plan to use NestJS in your project, NestJS doesn't work with ESM out of the box and you should be aware that you can run into issues. We suggest to use @adminjs/express
instead. This guide will show you how you can set up the latest AdminJS version with NestJS but do note that this is just a workaround until NestJS maintainers decide to move to or at least support ESM.
Example repository with AdminJS v7 working with NestJS & ESM: https://github.com/dziraf/adminjs-v7-with-nestjs
Make sure you have installed AdminJS packages described in Getting started article.
As of version 5.x.x
of @adminjs/nestjs
, the plugin only supports Nest servers that use Express. Fastify Nest servers are not currently supported.
If you are starting a new project, install nest-cli
and bootstrap the project:
@adminjs/nestjs
uses @adminjs/express
to set up AdminJS, because of this you have to additionally install it's dependencies:
Set moduleResolution
to nodenext
or node16
in your tsconfig.json
:
Next, add Nest plugin code into imports
of your AppModule
:
Now you should be able to start your AdminJS application:
AdminJS panel will be available under http://localhost:3000/admin
if you have followed this example thoroughly.
How to remove authentication?
If you don't want your admin panel to require authentication, simply follow the example above, but remove auth
and sessionOptions
configuration, for example:
Using AdminJS ESM packages
Since AdminJS version 7 and it's compatible packages are ESM-only, you cannot import them directly into your CommonJS Nest app. Instead, you have to use dynamic imports:
Last updated