Skip to content
Sheetwrite

Sheetwrite / Documentation

Installation

Install Sheetwrite for Vanilla, React, Vue, or Svelte and initialize its WebAssembly runtime.

Choose a framework in the header once. Every framework-aware example uses that preference, including the quick starts below and the lifecycle guide.

Terminal window
npm install @sheetwrite/core
Vanilla
import { createGrid, initSheetwrite } from "@sheetwrite/core";
import "@sheetwrite/core/styles.css";
await initSheetwrite();
const grid = createGrid(document.querySelector("#grid")!, { workbook, data });

The host owns initialization and must destroy the returned Grid when its DOM lifetime ends.

Runtime initialization

Zero-argument initSheetwrite() is canonical for the imperative package. It is re-entrant: concurrent calls share one initialization, retries work after failure, and repeats after success are no-ops. Framework adapters call the same initializer on mount.

Pass a source only for unsupported bundlers, public-asset policies, or controlled delivery:

Explicit WASM source
await initSheetwrite(source);

Accepted sources are BufferSource | URL | string | Request | WebAssembly.Module. The raw binary remains exported as @sheetwrite/wasm/wasm.

Explicit asset examples
// Vite-family URL
import wasmUrl from "@sheetwrite/wasm/wasm?url";
await initSheetwrite(wasmUrl);
// webpack asset URL
await initSheetwrite(new URL("@sheetwrite/wasm/wasm", import.meta.url));
// Public-copy fallback
await initSheetwrite("/sheetwrite_wasm_bg.wasm");

webpack and Next.js need no IgnorePlugin; package export conditions keep Node filesystem code out of browser graphs.

Failure UI and retries

React accepts fallback; Vue and Svelte use fallback content or slots. Initialization failures reach onInitializationError or Vue's initialization-error. A changed explicit source or remount can retry after failure.

Optional feature assets

Worker rendering and XLSX stay explicit. Import the Worker entry from @sheetwrite/core/worker. XLSX requires @sheetwrite/xlsx plus import "@sheetwrite/xlsx/register" before toolbar or programmatic export.