Skip to content

Example Features

The examples/ directory contains canonical feature implementations that serve as executable reference and test fixtures.

Feature matrix

FeaturePath prefixAuth requiredServer functions
feature-account/accountYesgetUserProfile, updatePreferences, getNotificationSettings
feature-dashboard/dashboardNogetOverviewStats, listReports, getReport, addReportNote
feature-lab-results/labsNolistLabPanels, getLabPanelResults
feature-medications/medicationsNolistMedications, prescribeMedication, discontinueMedication
feature-orders/ordersNolistOrders, validateOrder, createOrder, approveOrder, cancelOrder
feature-patient-list/patientsNosearchPatients, getPatient, getPatientCensus
feature-reference/referenceYesgetContextInfo, listPatients, saveNote, getProtectedData

Cross-feature cohesion

Patient-dependent features (labs, medications, orders, account) consume patient context from:

  • Host store key selectedPatient
  • patient:selected and patient:deselected events
  • patientId query parameter fallback (for direct deep-links)

The patient-list feature sets selectedPatient and publishes patient events. Global theme and locale are shared via the host store.

Recommended demo path:

  1. Open /patients
  2. Select a patient (writes selectedPatient and emits patient:selected)
  3. Navigate to /labs, /medications, or /orders
  4. Confirm context continuity via feature headers and RPC responses

Reference feature

examples/feature-reference/ is a comprehensive example demonstrating:

  • All host API surfaces (context, store, events, server functions, API proxy)
  • Team-owned auth and business logic patterns
  • authRequired: true configuration

See the Building Features guide for project structure and bootstrapping patterns.

Running examples

bash
# Build and publish all features locally
pnpm run build
pnpm run publish:local

# Start the host
pnpm run dev:host

# Visit any feature
# http://localhost:3000/dashboard
# http://localhost:3000/patients
# http://localhost:3000/labs

To develop a single feature with hot-reload:

bash
pnpm run dev:feature examples/feature-dashboard