Building and publishing a DHIS2 app using the app platform

Setup

Installing @dhis2/cli

Open up your favorite terminal emulator and run (choose one)

Using Yarn

yarn global add @dhis2/cli

Using npm

npm install --global @dhis2/cli

Verifying installation

We can verify our installation by running d2 --version which in our case prints 2.8.1. Your version might differ from ours, but as long as you do not get an error here, you should be good to go.

Initializing a new app

The d2 CLI provides a simple way of initializing a new app. Let us navigate (in the terminal emulator) to the where we want to create our project. This command requires yarn to be installed on our machine.

d2 app scripts init <app-name>

<app-name> must be replaced with whatever you want to call your new app.

We can now navigate into the newly created folder and start our development server.

yarn start

A web-browser window should have popped up greeting you with a login dialog (as shown below).

Newly initialized application login dialog
Newly initialized application login dialog

Entering our login credentials and signing in gives us the following screen.

Newly initialized application greeting screen
Newly initialized application greeting screen