---
title: "Code apps (npm) · Timeline docs · Ninth Forge"
url: https://ninthforge.com/docs/timeline/code-apps
description: "Use the Timeline as a React component in a Power Apps code app with the @ninthforge/timeline npm package."
---

# Code apps (npm)

In a Power Apps code app, or any React app, install `@ninthforge/timeline` and render `<Timeline items={…} />`. You hold the data; the Timeline shows it and tells you what the user changed. It’s the same component as the Power Apps control.

## Install

```
npm i @ninthforge/timeline@next
```

Until 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/timeline` installs the same release candidate; from 27 January it installs 1.0.0.

It needs React 16.14 or later and has no other runtime dependencies. Styles come with the component, and it uses your app’s font.

## Render it

```
import { useState } from 'react';
import { Timeline, type TimelineChange, type TimelineItem } from '@ninthforge/timeline';

const initial: TimelineItem[] = [
  { id: 'i1', name: 'Customer portal v2', lane: 'Customer', status: 'At risk', start: '2026-10-05', end: '2027-03-26', horizon: 'Now' },
  { id: 'i2', name: 'Portal launch', lane: 'Customer', start: '2027-03-29', dependsOn: ['i1'] }, // no end: a milestone
  { id: 'i3', name: 'Cloud migration', lane: 'Platform', status: 'On track', start: '2026-07-06', end: '2026-12-18', horizon: 'Now' },
  { id: 'i4', name: 'Board strategy day', lane: 'Growth', status: 'On track', start: '2026-11-20', end: '2026-11-20', milestone: false },
  { id: 'i5', name: 'Voice assistant', lane: 'Customer', status: 'Not started', horizon: 'Later' } // no dates: "Not scheduled"
];

export function Roadmap({ licenseKey, tenantId }: { licenseKey?: string; tenantId?: string }) {
  const [items, setItems] = useState(initial);

  // Save to your backend; throw (or reject) to put the item back with a message.
  const onItemChange = async (c: TimelineChange) => {
    setItems((list) => list.map((i) => (i.id !== c.id ? i : { ...i, ...(c.start ? { start: c.start } : {}), ...(c.end ? { end: c.end } : {}) })));
  };

  return (
    <div style={{ height: 560 }}>
      <Timeline
        title="Group roadmap"
        items={items}
        laneOrder={['Customer', 'Growth', 'Platform']}
        fiscalYearStart={7}
        onItemChange={onItemChange}
        licenseKey={licenseKey}
        tenantId={tenantId}
      />
    </div>
  );
}
```

## Data

-   **Dates** are ISO `YYYY-MM-DD` strings. The end is inclusive. Changes come back the same way.
-   **Milestones:** no `end`, or `end` equal to `start`. `milestone: false` keeps a one-day item as a bar; `milestone: true` forces a diamond.
-   **No dates:** the item waits in the “Not scheduled” tray in Dates mode, and shows normally in Now · Next · Later.
-   **`lane`** groups items into swimlanes; items without one go in “No lane”, last. **`horizon`** is Now, Next or Later.
-   **`dependsOn`** is a list of item ids, drawn as read-only connectors.
-   **Bad data doesn’t break the roadmap:** unreadable dates count as missing, reversed dates are swapped, and fields of the wrong type are treated as text.

## Saving changes

`onItemChange` gets every move, resize and undo: `{ id, start?, end?, previous, source }`, with only the fields that changed. Return a promise for an optimistic save: the Timeline keeps the change while it’s pending, and puts it back with the error message if the promise rejects. Then pass the updated items back in.

## Useful props

| Prop | What it does |
| --- | --- |
| `fiscalYearStart` | First month of the fiscal year (1–12). Quarters and halves read “Q1 FY27”. |
| `zoom`, `defaultZoom`, `onZoomChange` | `month`, `quarter` or `half`. |
| `mode`, `defaultMode`, `onModeChange` | `dates` or `horizon` (Now · Next · Later). |
| `colorBy` | `status` (default) or `lane`. |
| `statusColors`, `laneColors` | Value → hex, checked before the built-in colours. |
| `laneOrder` | Lane names in order; others follow alphabetically. |
| `showDependencies` | Draw connectors from `dependsOn`. |
| `editable` | `false` turns editing off; `{ resize: false }` allows moves only. An item with `readOnly: true` is locked. |
| `onSelect(id)`, `onOpen(item)` | Selection, and Enter or double-click on an item. |
| `loading` | Shows “Loading items…” instead of an empty roadmap while you fetch. |
| `theme`, `accent`, `dir` | `'light'` or `'dark'`, an accent colour, `'rtl'`. |

## Licence

Pass your Plan key as `licenseKey` and your tenant ID as `tenantId`. See [Licensing](https://ninthforge.com/docs/timeline/licensing). The check is offline; the component makes no network calls.

Last updated 14 November 2026
