Skip to content

Quick start ​

Install ​

sh
npm install @byfungsi/nori

For the React renderer, also install compatible React peers:

sh
npm install react@^19 react-dom@^19

Headless use does not require React. The package is ESM; use an ESM application or a compatible bundler. Repository development requires Node 22.12 or later. Native bindings are future work.

For editor appearance, see Styling and theming. Nori does not ship an editor stylesheet; the guide provides a complete application CSS starter.

Calculate and persist a workbook ​

This is a complete, typechecked example. Expected failures are Result values; this short program chooses to throw after checking them. An application should display or return these errors at its boundary.

ts
import { createEmptySnapshot, createWorkbook } from "@byfungsi/nori";

export function makeWorkbook() {
  const created = createWorkbook(createEmptySnapshot());
  if (!created.ok) throw created.error;
  const workbook = created.value;
  const sheetId = workbook.getState().activeSheetId;
  const edited = workbook.dispatch({
    type: "batch",
    commands: [
      { type: "setCell", sheetId, address: "A1", cell: { value: 100 } },
      { type: "setCell", sheetId, address: "A2", cell: { value: 50 } },
      {
        type: "setCell",
        sheetId,
        address: "A3",
        cell: { value: null, formula: "SUM(A1:A2)" },
      },
    ],
  });
  if (!edited.ok) throw edited.error;
  return workbook;
}

const workbook = makeWorkbook();
const sheetId = workbook.getState().activeSheetId;
console.log(workbook.getCellValue(sheetId, "A3")); // 150
const json = JSON.stringify(workbook.exportSnapshot());
const restored = createWorkbook(JSON.parse(json));
if (!restored.ok) throw restored.error;

WorkbookSnapshot is immutable JSON-compatible document data. Workbook is a live runtime with commands, subscriptions, history and calculated values. Persist the snapshot, never the runtime object. Exported cell values may be old formula caches; read calculated results through getCellValue.

Choose an import ​

ImportPurpose
@byfungsi/noriConvenient model constructors, XLSX parser and runtime
@byfungsi/nori/modelCanonical types, validation, addresses, ranges and Result helpers
@byfungsi/nori/coreRuntime, commands, selection and layout
@byfungsi/nori/csvText CSV to a single-sheet snapshot
@byfungsi/nori/xlsxByte-to-snapshot adapter
@byfungsi/nori/formulaAST parser, evaluator, registry and dependency graph
@byfungsi/nori/pivotSemantic grouping and aggregation
@byfungsi/nori/reactReact DOM components and hooks

Only /react imports React. Prefer /core when you do not need XLSX dependencies. Internal workspace names are implementation details and must not appear in consumer code.

Continue with React, XLSX import, or headless recipes.

Nori 0.2.0 · Initial milestone · Explicit compatibility boundaries.