dhtmlxGantt with React
This tutorial covers the usage of the JS DHTMLX Gantt in React apps. If you want to use the official React Gantt component, please refer to React Gantt article.
You should be familiar with the basic concepts and patterns of React to use this documentation. If you are not, please refer to the React documentation for a getting-started tutorial.
DHTMLX Gantt is compatible with React. You can check the corresponding example on GitHub: DHTMLX Gantt with React Demo.
Creating a project
Before you start to create a new project, install Node.js.
You can create a basic React project using the following command:
npx create-vite my-react-gantt-app --template react
Installation of dependencies
Next you should go to the app directory. Let's call our project my-react-gantt-app and run:
cd my-react-gantt-app
After that you should install dependencies and start the dev server. For this, you need to make use of a package manager:
- if you use yarn, you need to call the following commands:
yarn install
yarn dev
- if you use npm, you need to call the following commands:
npm install
npm run dev
You should now have your React project running on http://localhost:5173.

Creating Gantt
Now we should get the DHTMLX Gantt code. Firstly, we need to stop the app by pressing Ctrl+C in the command line. Then we can proceed with installing the Gantt package.
Step 1. Package installation
The PRO versions of the library are available for the npm/yarn install from our private repository, please follow this instruction to gain access to it.
After you've got the Evaluation version of the Gantt, you can install it with the following commands:
- for npm:
npm install @dhx/trial-gantt
- for yarn:
yarn add @dhx/trial-gantt
Alternatively, since the zip-package of the library is structured as an npm module, you can install it from a local folder.
Step 2. Component creation
Now we should create a React component, to add a Gantt into the application. Let's create the Gantt.jsx file in the src/ directory.
Importing source files
Open the newly created Gantt.jsx file and import Gantt source files. Note that:
- if you've installed the Gantt package from a local folder, your import paths will look like this:
import { Gantt} from "dhtmlx-gantt";
import "dhtmlx-gantt/codebase/dhtmlxgantt.css";
- if you've chosen to install the trial version, the import paths should be as in:
import { Gantt} from "@dhx/trial-gantt";
import "@dhx/trial-gantt/codebase/dhtmlxgantt.css";
In this tutorial, we will use the trial version of Gantt.
Setting the container and adding Gantt
To display Gantt on the page, we need to set the container to render the component inside. The Gantt.jsx file should contain the following code:
import { useEffect, useRef } from "react"; /*!*/
import { Gantt } from "@dhx/trial-gantt";
import "@dhx/trial-gantt/codebase/dhtmlxgantt.css";
export default function GanttView() { /*!*/
let container = useRef(); /*!*/
useEffect(() => { /*!*/
let gantt = Gantt.getGanttInstance(); /*!*/
gantt.init(container.current); /*!*/
return () => { /*!*/
gantt.destructor(); /*!*/
container.current.innerHTML = ""; /*!*/
}; /*!*/
}, []); /*!*/
return <div ref="{container}" style={{}} {width: "100%", height: "100%"} }></div>; /*!*/
} /*!*/