Skip to content

Add a sidebar-navigated page ​

Goal: add a "Reports" link to the host EMR's sidebar that opens a new page you control.

Prerequisites:

  • An Orion app generated with orion init and npm installd
  • Sandbox configured (orion config sandbox) and orion dev ready to run

The mental model ​

A "navigated page" is two manifest entries in orion-app.json that point at the same path:

  • a page extension (extensions.pages[]) owns the route and renders the content
  • a nav extension (extensions.navigation[]) puts a link to that route into the sidebar, header, settings, or patient-actions menu

You can have a page without a nav (deep-linked from a block or an action) or a nav without a page (linking to a host route), but the common case is both, generated together.

Step 1 — Pick the placement ​

The nav generator's --placement flag takes one of the four areas the host EMR exposes. Print them so you don't have to guess:

bash
orion generate list nav

For this recipe, sidebar. (Use the same list command for block, widget, and action catalog tokens.)

Step 2 — Generate the page first ​

Generate the page that owns /reports:

bash
orion generate page reports --path /reports

This writes:

  • An entry under extensions.pages[] in orion-app.json with path: "/reports" and component: "Reports"
  • src/pages/Reports.tsx — a placeholder page component you'll edit
  • An import of Reports into your app's entry file (src/main.tsx or src/index.tsx)

On the legacy template the generator also writes the createPage(ReportsComponent) registration, so the page is fully wired after the next build. On the SMART template it prints the JSX snippet to paste into mount().

Step 3 — Generate the nav entry ​

Now add the sidebar link. Use a different <id> than the page — see the callout below for why:

bash
orion generate nav reports-link --placement sidebar --path /reports --icon FileText

This writes:

  • An entry under extensions.navigation[] in orion-app.json with placement: "sidebar" and target: "/reports"
  • src/nav/ReportsLink.tsx — a placeholder file (nav entries don't render their own component; the host reads the link from the manifest)
  • An import of ReportsLink into your entry file

--icon accepts any Lucide icon name. orion generate list nav reminds you of the placements; for icons, see lucide.dev.

Use a different <id> for the nav than for the page

Using reports for both would scaffold two named imports of Reports — one from @/pages/Reports, one from @/nav/Reports — into the same entry file. That's a duplicate identifier; tsc errors and the build fails. Keep the nav slug distinct (reports-link, reports-nav, etc.) and the imports stay clean.

Step 4 — Verify ​

bash
orion dev

In the host EMR sandbox, the sidebar gains a "Reports" entry. Click it — your placeholder src/pages/Reports.tsx renders inside the host frame. Edit the page; HMR picks up the change.

Recap ​

StepCommandWhat it lands
1orion generate list nav(read-only) prints valid placements
2orion generate page reports --path /reportspage extension + src/pages/Reports.tsx + import
3orion generate nav reports-link --placement sidebar --path /reports --icon FileTextnav extension + src/nav/ReportsLink.tsx + import
4orion devrenders in the sandbox

Page-first matches the mental flow ("I built a thing, now I want people to find it"), but the order doesn't strictly matter — either way each generator writes its own manifest entry and source file, and the host resolves the sidebar link to the page at render time.

Documents @orion-ehr/cli v0.0.16 — released under the MIT License.