AdonisJS Project Start-Up
AdonisJS Project Start-Up
Prerequisites
Adonis requires Node version 20.6 or higher. We recommend using the latest version of Node, or Node version 21.0.0. You can check your node version by running node -v within your global Terminal. We recommend using a Node version manager, which will be covered in a separate guide.
Installation
Starting up a new Adonis project can be done through utilizing the npm init **command within a terminal that lives at the root of where you would like to organize your project. By using npm init, you can specify some configuration options that the project should use. This is done by appending CLI flags to the end of your core npm init command.
If you do not specify any CLI flags, you will be asked a series of questions which will allow you to specify your config options anyways.
Command without CLI Flags:
npm init adonisjs@latest hello-world
This command will start the creation process with the latest version of AdonisJS.
Command with CLI Flags:
Optionally, you can provide CLI flags to speed up the process of creating a new Adonis project.
Flag Options:
--kit: Select the starter kit for the project. You can choose between web, api, or slim.--db: Specify the database dialect of your choice. You can choose between sqlite, postgres, mysql, or mssql. Defaults tosqlite.--git-init: Initiate the git repository. Defaults tofalse.--auth-guard: Specify the authentication guard of your choice. You can choose between session, access_tokens, or basic_auth. Defaults tosession.--install: Skip the prompt to install dependencies. Use the--no-installflag to create a project without installing any dependencies.
npm init adonisjs@latest hello-world -- --kit=api --auth-guard=session --db=postgres
In the above example, we are using some CLI flags to bypass some configuration questions that you will be presented with otherwise. More specifically, we are telling npm to instantiate a new project that uses the latest version of AdonisJs that is called “hello-world”, for which we will use the api starter kit, session auth-guard, and Postgres database.
This will auto-configure pretty much all of the config options that you would otherwise have to configure manually.
Brem Standards
At Brem, we will be using a variety of the options that are mentioned above. Each project will be tailored to what best suites their use-case. Below, you will find the standard Brem start-up command for a “standard” project. This will occasionally change if the project scope requires it.
npm init adonisjs@latest project-name -- --kit=web --auth-guard=session –db=postgres --install --git-init=false
Farther Reading
Adonis is packed with fun features to use in development. In future guides/references, we will cover additional configuration processes that will enhance your development experience.