AdonisJS is a Node.js framework, and hence it requires Node.js to be installed on your computer. To be precise, we need at least the latest release of
You can check the Node.js and npm versions by running the following commands.
# check node.js version
If you don't have Node.js installed, you can download the binary for your operating system from the official website.
Creating a new project
npm init adonis-ts-app@latest hello-world
yarn create adonis-ts-app hello-world
pnpm create adonis-ts-app hello-world
The installation process prompts for the following selections.
You can choose between one of the following project structures.
webproject structure is ideal for creating classic server-rendered applications. We configure the support for sessions and also install the AdonisJS template engine.
apiproject structure is ideal for creating an API server.
slimproject structure creates the smallest possible AdonisJS application and does not install any additional packages, except the framework core.
The name of the project. We define the value of this prompt inside the
Optionally, you can configure eslint and prettier. Both the packages are configured with the opinionated settings used by the AdonisJS core team.
Configure Webpack Encore
Optionally, you can also configure Webpack Encore to bundle and serve frontend dependencies.
Please do note, AdonisJS is a backend framework and does not concern itself with front-end build tools. Hence the Webpack setup is optional.
Starting the development server
After creating the application, you can start the development server by running the following command.
node ace serve --watch
--watchflag is meant to watch the file system for changes and restart the server automatically.
By default, the server starts on port 3333 (defined inside the .env file). You can view the welcome page by visiting: http://localhost:3333 .
Compiling for production
node ace build --production
The compiled output is written to the
build folder. You can
cd into this folder and start the server by directly running the
server.js file. Learn more about the TypeScript build process