Adonis JS | How To Create a Project

Raviya Technical
AdonisJS
Published in
2 min readJul 1, 2023

Introduction:

Adonis JS is a robust Node.js web application framework that enables developers to create efficient and scalable applications. In this comprehensive guide, we will walk you through the process of creating a project in Adonis JS. We will also explore the different project structure types available and provide instructions on running the server project for testing and development purposes.

Step 1: Initializing the Adonis JS Project

To begin, let’s initialize a new Adonis JS project using the npm (Node Package Manager) command. Launch your command line interface and navigate to the desired project directory. Execute the following command to initiate the project:

npm init adonis-ts-app@latest project-name

Ensure that you replace project-name with the specific name you want for your project. This command initializes a new Adonis JS project with built-in TypeScript support.

Step 2: Selecting the Project Structure Type

Adonis JS offers three primary project structure types: web, API, and slim. Each structure is designed to cater to distinct use cases. Let’s take a closer look at each option:

  • Web: Ideal for developing full-stack web applications that incorporate server-rendered views. This structure encompasses essential features such as routing, controllers, views, and middleware.
  • API: Tailored for API-only projects where the primary focus is on building APIs and delivering JSON responses. It includes features such as routing, controllers, and middleware, while excluding server-rendered views.
  • Slim: A minimalist setup that provides flexibility for developers who prefer a more customized project structure. It includes only the essential files required for a basic Adonis JS project.

Select the project structure type that aligns best with your specific project requirements, and proceed to the next steps accordingly.

Step 3: Running the Server Project

Once your project is initialized and you have chosen the appropriate structure type, it’s time to run the server project for testing and development. Follow these instructions:

node ace serve --watch

By executing this command in your project’s root directory, you will start the Adonis JS server in watch mode. The watch mode automatically restarts the server whenever changes are detected in your project files. You can now access your application through the specified local development server URL.

--

--