Code apps (npm)
In a Power Apps code app, or any React app, install @ninthforge/gantt and render <Gantt tasks={…} /> with your rows mapped to tasks. You load and save the data, and the component tells you what the user changed. It’s the same component as the Power Apps control.
Install
npm i @ninthforge/gantt@nextUntil the launch on 27 January 2027, the package is a release candidate (1.0.0-rc.N). Install it with @next to keep getting each new release candidate. For now npm i @ninthforge/gantt installs the same release candidate; from 27 January it installs 1.0.0.
It needs React 16.14 or later (the demo runs on React 18) and has no other runtime dependencies. Its styles come with the component, and it uses your app’s font.
Render it
import { Gantt, type GanttChange, type GanttTask } from '@ninthforge/gantt';
const tasks: GanttTask[] = [
{ id: 'p1', name: 'Design', kind: 'phase' },
{ id: 't1', name: 'Wireframes', parentId: 'p1', start: '2027-02-01', end: '2027-02-05', progress: 60 },
{ id: 't2', name: 'Review', parentId: 'p1', start: '2027-02-08', end: '2027-02-09', dependsOn: ['t1'] },
{ id: 'm1', name: 'Sign-off', kind: 'milestone', date: '2027-02-10', dependsOn: ['t2'] }
];
export function Plan() {
return (
<div style={{ height: 560 }}>
<Gantt
tasks={tasks}
title="Website relaunch"
licenseKey={import.meta.env.VITE_NINTHFORGE_KEY}
tenantId="<your Entra tenant ID>"
onTaskChange={(change: GanttChange) => save(change)}
/>
</div>
);
}- Dates are ISO strings (
YYYY-MM-DD). End dates are inclusive. - Phases (
kind: 'phase') without dates span their children. - Milestones use
date. dependsOnlists finish-to-start predecessors by id.
Save edits
onTaskChange gets every edit: { id, …changed fields, previous, source }. Return a promise for an optimistic save. The chart keeps the edit while the promise is pending. If the promise rejects, it reverts the task and shows the error message in a toast. Undo and redo come through the same callback, with source set to 'undo' or 'redo'.
async function save(change: GanttChange) {
const { id, previous, source, ...fields } = change;
await updateTask(id, fields); // your Dataverse call; throw to revert
}Then pass the updated rows back in tasks. The component reconciles once your data matches the edit.
Useful props
| Prop | What it does |
|---|---|
onAddTask(request) |
“+ Add task”, Insert and the row menu. request has parentId, afterId and a suggested start. Create the row, then add it to tasks. |
onOpen(task) |
Enter or double-click on a task. |
editable |
false turns editing off. To turn off single actions, pass e.g. { link: false, add: false }. task.readOnly locks one row. |
singlePredecessor |
At most one predecessor per task (for a single lookup column). |
defaultZoom |
'week', 'month' or 'quarter'. |
theme, accent |
'light' or 'dark', and an accent colour. |
columns |
Grid columns, e.g. { owner: true, start: true, end: true }. |
workingWeek |
'mon-fri' (default) or 'all'. |
dir |
'rtl' for right-to-left layouts. |
Licence
Pass your Plan key as licenseKey and your tenant ID as tenantId. See Licensing. The check is offline; the component makes no network calls.
Last updated