- Create a web app from scratch using Domo’s React app template
- Use the Mapbox GL JS library to build a custom map
- Wire the app to a dataset in Domo and fetch data to add points to the map
Step 1: Setup and installation
Before beginning, please make sure you’ve successfully installed the Domo Apps CLI and followed the basic setup and installation instructions found here. When following the article, please skip
Step 3: Create a New App. We will be creating a React app instead of a simple Javascript app.
Initialize a React project using Domo’s template by following the steps in this article.
Once your project has been created, open it in your preferred IDE and run yarn (or npm install) to install all required dependencies. When you’re ready, run yarn start (or npm start) to start developing locally.
Step 2: Sign up for a free Mapbox account
If you don’t already have a Mapbox account, you can create one for free here. This is a requirement to get your own custom app running with Mapbox. Once you’ve created your account, you should be able to get your personal
Access tokens at the bottom of your account home screen. If you’re having trouble finding them, or you’d like to learn more about access tokens, read Mapbox’s support article on Access Tokens.
Step 3: Set up app components
Open the
public and src folders to see the files that were auto-generated for you in Step 2. For this tutorial, we will only make changes to the App.js, App.css, and manifest.json files.
-
App.jsandApp.csswill contain the code to build the mapbox app and style it how we want. -
The
manifest.jsonfile is a special Domo file that is required for building apps on the Domo App Framework. We will use this file to wire our app to a dataset in Domo. What is the manifest file?
App.js to include a container div for a map. We will also add a couple of refs to control the content of our container. Replace everything inside of App.js with the following lines of code:
App.css with this simple CSS class:
Step 4: Instantiate Mapbox
First, install the
mapbox-gl package using either yarn or npm. Run one of the following commands in your terminal from the context of your app.
$ yarn add mapbox-gl or $ npm install mapbox-gl
Next, add the following imports to the very top of your App.js file to bring in the Mapbox GL JS library and dependencies.
useEffect to our component to instantiate an instance of Mapbox once our component has loaded into the DOM and is ready to render the map. Below your useRef lines of code, add the following snippet:
YOUR_MAPBOX_ACCESS_TOKEN with your own personal Mapbox access token. You should have seen this when completing Step 3. This will give your app the access it needs to interact with the Mapbox GL JS library.
Once you’ve followed all of these steps, your App.js file should look like this:
yarn start or npm start
Check your browser at localhost:3000, where your app should be running. You should see an interactive globe map. You can use your scroll wheel to zoom in and out, and you can drag the globe to rotate it.

Step 5: Style map and add a few points
Mapbox provides a way to create custom map styles inside their Mapbox Studio feature. We won’t be building one in this tutorial, but you can find out how to do it yourself by following their guide, Create a custom style. We’ve created a simple custom style already and we are providing you the json file that will allow you to use it in your app. You can get it from the code repo for this tutorial. Please download the map-style.json file here. You’ll want to add the
map-style.json file to your src folder. Then, bring it into your app by adding this line of code at the top of your App.js file:

useEffect that will iterate over the cities and turn them into points on our map. Mapbox uses the latitude and longitude of our data points to position elements on the map. We are telling Mapbox to add a layer of circles using our data, and then we pass the radius, color, and opacity to customize the look. Update your useEffect to look like this:

Step 6: Wire data to our app
Now that we have our map looking how we want it, it’s time to add some real data to it. Building Domo apps on the App Framework becomes the most powerful when we’re able to leverage connections with your data via wiring to DataSets, AppDB collections, Workflows, and more. For this tutorial, we will be wiring our app to a DataSet that contains population data for cities all over the world. First, you will want to download the
World_Cities.csv file from the code repo, which you can find here.
Then, upload the DataSet to your Domo instance. Go to the Data tab in Domo, click on CONNECT DATA at the top of the screen, then select Upload a spreadsheet. You’ll then be able to select the file from your machine or drag and drop into the UI. Click through the file upload screens and save the dataset without making any modifications.
Now, return to your app and open the manifest.json file. We’re going to add an entry to the mapping property for the dataset we just created in Domo. Update the contents of your manifest.json file to look like this:
YOUR_DATASET_ID with the unique ID for the dataset you created in your Domo instance a moment ago. You can find the ID in the URL bar when viewing the dataset.

manifest.json file. Let’s do that now.
Login to your Domo instance from the command line by running this command:
domo login
You will be prompted to select a Domo instance, or enter a new one. Enter your assigned instance URL and then press enter (e.g. ‘my_company.domo.com’). You’ll then be presented with a login screen and the Domo CLI will be authorized on your instance.
Next, run yarn upload or npm upload.
This will build your project and create a new app Design in your Domo instance. If the command runs successfully, you’ll see something like this in your terminal when it’s finished:

MORE option at the top, and select Asset Library. You should be able to find your World Map App here. Click on the asset to open its details. Below the name of the asset, you’ll see a Design Id. Copy that.

Design Id to the manifest.json file. After the closing square brackets of your mapping property, add a comma and a new line. Then, add this line of code:
Cards tab at the top, and then select Create Card in the top right. This will open the card details screen. From this view, you should see a preview of your App as well as all of the Domo entities that are/can be wired to it. Since we added our DataSet Id to our manifest.json file earlier, you should see that the World_Cities.csv file is wired to your app. If not, you can select it manually.
Click Save & Finish in the top right to save your new Card.
Now, return to the Asset Library and find your Design again. Click on the Cards tab at the top and you should see your newly created card. Find the Proxy Id property and copy that value.

manifest.json file in your app and add another line below the previous addition:
manifest.json file should look something like this:
Step 7: Query data and render points on the map
We are going to use the Domo CLI (aka
ryuu.js from within an app) to fetch data from our instance. What is the Domo CLI?
Install the library using yarn add ryuu.js or npm install ryuu.js
Then, import it into your app by adding this line at the top of your App.js file:
useEffect to your component that uses domo.get to fetch data from the World_Cities DataSet.
GET endpoint uses the dataset alias, which we set in our manifest.json file. We set the alias as geoData, but you can set it to whatever you’d like.
Make sure your app is running in the browser and refresh the page. In your Javascript console, you should see over 45,000 rows of data being printed (you can open the console by right-clicking on the screen and clicking Inspect). This is just a quick check to make sure our data is being fetched as expected, but now we’re going to add the data to our map.
We’re going to add a few things here. Add a useState to store our data points below our useRef lines, then set the points after fetching the data. Also create a couple of helper functions to determine each point’s radius and color.
useEffect (the one that renders the map) to make it dependent on our points array and prevent it from rendering anything before the data is ready.
App.js file should end up looking like this:
