This tutorial will help you set up your local development environment to build your first DHIS2 app using the DHIS2 Application Platform, which provides a full-featured DHIS2 app, with out-of-the-box tools and components ready to be customized for your use case.
In this section we will:
- Install Node.js and Yarn
- Install the DHIS2 CLI
- Initialize a new DHIS2 app
You will need to have the following installed before proceeding:
- Install Node.js
Make sure that you are running a compatible version of Node as using older versions may throw some errors during setup.
- Install Yarn
2. Install the DHIS2 CLI
We'll start by installing the DHIS2 CLI (Command Line Interface) globally.
@dhis2/cli package provides a set of tools that are useful when developing DHIS2 apps. It contains a number of modules that lets you quickly create and maintain DHIS2 applications. It also allows you to manage local DHIS2 instances by running simple commands.
@dhis2/cli globally run the following command using
yarn global add @dhis2/cli
Verify your installation and check all the commands that are available to you:
You’re now ready to start using
@dhis2/cli commands to create a new app! ✨
3. Initialize a new DHIS2 app
Now you are ready to use the
d2 CLI tool to create your first DHIS2 app.
d2 CLI provides a simple way of initializing a new app. We'll use the d2-app-scripts init command to do that.
From your terminal, navigate to the where you want to create your project and then run the following command:
d2 app scripts init <app-name>
# <app-name> must be replaced with your app name.
We can now navigate into the newly created folder and start your application locally:
Connecting your app to a DHIS2 instance
yarn start a web-browser window should have popped up greeting you with a login dialog at http://localhost:3000.
Enter your own development instance of DHIS2 as the server URL and the username and password of the default admin user (as shown in the example below):
You will then see your newly initialized application greeting screen like this one 👇
Congratulations! You are now ready to start developing a DHIS2 application! 👏🏽
Want to learn more?
Watch this short video to get an overview of DHIS2 application development and the App Platform (30 min)
Check the App Platform documentation
In the next tutorial you will learn how to use the DHIS2 UI library and add its components to your application!