- Eliminate DOM Bottlenecks: Replace thousands of heavy HTML
<td>elements with a custom HTML5 Canvas rendering engine that maintains 60 FPS scrolling. - Architect for Scale: Process datasets exceeding 1,000,000 active cells while keeping client-side browser memory consumption under 150 MB.
- Implement Plugin Architecture: Decouple spreadsheet core engines, rendering layers, and formula calculators into isolated micro-packages.
- Enable Real-Time Co-authoring: Sync state across distributed web client sessions using low-latency Operational Transformation (OT) and WebSockets.
- Integrate AI Agent Interfaces: Connect frontend agent execution loops using the AG-UI protocol for automated data analysis and formatting.
- Optimize Viewport Redraws: Use spatial indexing and dirty region repainting to render only visible grid coordinates during scroll events.
Traditional browser-based spreadsheets hit a hard technical wall when rendering thousands of interactive grid cells. Building complex web tables using standard HTML document object model (DOM) nodes rapidly overwhelms browser memory, dropping frame rates from 60 FPS to unusable slideshow levels during fast scrolling.
Quick Answer: Univer is an open-source, TypeScript-first engine designed to render complex collaborative spreadsheets on HTML5 Canvas. By separating core state, formula engines, and view rendering into isolated plugins, Univer handles datasets with over 1,000,000 cells at 60 FPS while supporting low-latency multi-user collaboration and native AI agent interactions.
In March 2026, web applications demand rich data manipulation directly inside client browsers. Legacy tools rely heavily on traditional <table> or <div> structures. Each cell requires event listeners, style compute passes, and layout recalibrations that lock up the main JavaScript execution thread. When enterprise users load heavy datasets, memory consumption spikes past 1.5 GB within minutes.
The open-source framework univer (developed by DreamNum) takes a fundamentally different engineering path. By utilizing a hybrid Canvas rendering engine and a strict command mutation model, it bypasses DOM recalculation overhead entirely. In this guide, we will break down the underlying system architecture of Univer and walk through building a production-ready, collaborative web spreadsheet step by step.
Understanding the Univer Engine: Canvas Rendering vs. DOM Overload
To appreciate why Univer achieves smooth scrolling across massive worksheets, we must analyze how web browsers parse visual elements. Every standard HTML element added to the document page adds weight to the browser's render tree. A table with 100 rows and 50 columns produces 5,000 distinct DOM elements. Each element requires paint, layout, and style recalculation whenever a user changes a cell value.
Univer replaces these individual elements with a single <canvas> context. Instead of letting the browser calculate cell boundaries, Univer's core engine maintains an internal spatial grid index. It only computes pixel coordinates for visible rows and columns currently located inside the user's viewport screen.
What happens when a user scrolls through a dataset of 1,000,000 cells? Instead of destroying and recreating thousands of DOM nodes, Univer updates its internal offset variables and triggers a single hardware-accelerated draw call. The browser paints raw pixels onto the GPU surface in less than 4 milliseconds, holding a rock-steady 60 FPS refresh rate.
Architecturally, Univer decouples business data from UI presentation using three distinct core pillars:
- Core State Layer (Univer Core): Manages the document snapshot tree, history stack, configuration objects, and lifecycle hooks.
- Render Engine Layer (Engine Render): Handles low-level Canvas 2D painting, custom viewports, font metrics calculation, and spatial hit testing.
- Formula Engine Layer (Engine Formula): Operates an asynchronous execution pipeline for parsing functions, resolving cell dependencies, and evaluating multi-sheet formulas.
Architecture Comparison: Univer vs. Legacy Web Spreadsheets
Selecting the right frontend grid infrastructure requires comparing hardware consumption, rendering strategies, and extendibility models across available open-source and proprietary frameworks.
| Framework / Metrics | Rendering Tech | Max Cells @ 60 FPS | Client Memory (100k Cells) | Collaboration Protocol | AI Agent Support |
|---|---|---|---|---|---|
| Univer Architecture | HTML5 Canvas 2D | 1,000,000+ | ~120 MB | Operational Transformation (OT) | Native (AG-UI Protocol) |
| Handsontable | DOM HTML Elements | ~20,000 | ~680 MB | Custom / Manual Sync | Third-Party Wrapper |
| Luckysheet | DOM + Canvas Hybrid | ~50,000 | ~450 MB | WebSocket Events | None |
| FortuneSheet | DOM Structure | ~40,000 | ~510 MB | Custom WebSocket Server | None |
Notice the massive difference in client-side memory footprint. Because DOM-based libraries retain active Node instances for hidden off-screen cells, their heap allocation scales linearly with dataset size. Canvas engines like Univer maintain flat array buffers, keeping memory footprint practically constant regardless of how many off-screen rows exist.
Step-by-Step Implementation: Building a Collaborative Univer Spreadsheet
Let's walk through building a full-featured collaborative web spreadsheet using TypeScript and modern ESM build tools. We will initialize the rendering context, wire up formula calculation, and attach operational transformation sync listeners.
Step 1: Setting Up the Project Environment
Initialize a modern Vite project using TypeScript support and install the required core packages from the official Univer package registry.
npm create vite@latest univer-spreadsheet -- --template vanilla-ts
cd univer-spreadsheet
npm install @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/engine-formula @univerjs/sheets @univerjs/sheets-ui @univerjs/docs @univerjs/ui
Ensure your CSS entry point imports the fundamental stylesheet variables exported by the core package. This guarantees proper UI icon scaling and canvas overlay alignment.
/* src/style.css */
@import "@univerjs/design/lib/index.css";
@import "@univerjs/ui/lib/index.css";
@import "@univerjs/sheets-ui/lib/index.css";
#app {
width: 100vw;
height: 100vh;
overflow: hidden;
}
Step 2: Instantiating the Engine and Canvas Rendering Layer
Open src/main.ts and initialize the central Univer core container instance. We register the rendering engine plugins alongside the base UI framework controllers.
import { Univer, LocaleType } from "@univerjs/core";
import { RenderEngine } from "@univerjs/engine-render";
import { FormulaEngine } from "@univerjs/engine-formula";
import { UniverUIPlugin } from "@univerjs/ui";
import { UniverSheetsPlugin } from "@univerjs/sheets";
import { UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
import "@univerjs/ui/lib/index.css";
import "@univerjs/sheets-ui/lib/index.css";
// Initialize core Univer instance
const univer = new Univer({
locale: LocaleType.EN_US,
}); For more details, see Ars Technica. For more details, see Wikipedia. For more details, see The Verge. For more details, see MDN Web Docs.
// Register execution engines
univer.registerPlugin(RenderEngine);
univer.registerPlugin(FormulaEngine);
// Register UI and Sheet controllers
univer.registerPlugin(UniverUIPlugin, {
container: "app",
header: true,
toolbar: true,
footer: true,
});
univer.registerPlugin(UniverSheetsPlugin);
univer.registerPlugin(UniverSheetsUIPlugin);
Step 3: Creating and Populating the Initial Workbook
Once the core plugins are loaded, instantiate a target workbook instance. We define initial cell values, column widths, formula definitions, and background formatting using standardized JSON schema objects.
// Create a initial workbook instance containing sample transactional data
const workbook = univer.createUnit(1, {
id: "workbook-01",
name: "Quarterly Financial Analysis",
sheetOrder: ["sheet-01"],
sheets: {
"sheet-01": {
id: "sheet-01",
name: "Q1 Projections",
rowCount: 1000,
columnCount: 20,
cellData: {
0: {
0: { v: "Region" },
1: { v: "Revenue" },
2: { v: "Expenses" },
3: { v: "Net Margin" }
},
1: {
0: { v: "North America" },
1: { v: 1250000 },
2: { v: 820000 },
3: { f: "=B2-C2" } // Dynamic dynamic formula calculation
},
2: {
0: { v: "Europe" },
1: { v: 940000 },
2: { v: 610000 },
3: { f: "=B3-C3" }
}
}
}
}
});
When this code executes in the browser, Univer bootstraps an interactive canvas surface inside the #app container. The formula engine immediately parses the cell formula strings (=B2-C2), evaluates dependencies, and renders computed numerical values within milliseconds.
Step 4: Configuring Operational Transformation (OT) for Multi-User Sync
Real-time collaborative editing requires capturing granular changes—known as mutations—and propagating them over low-latency WebSockets. Univer avoids re-sending full document snapshots. Instead, it emits localized mutation operations that execute deterministically on remote client instances.
import { ICommandService } from "@univerjs/core";
// Access the internal central Command Service module
const commandService = univer.getUniverInjector().get(ICommandService);
// Establish WebSocket connection to backend sync server
const socket = new WebSocket("wss://sync.yourdomain.com/sheets/workbook-01");
// Intercept local mutations executed by user interactions
commandService.onCommandExecuted((commandInfo) => {
// Filter for structural sheet mutations only
if (commandInfo.type === 2 /* Mutation Type */) {
const payload = JSON.stringify({
unitId: "workbook-01",
mutation: commandInfo,
timestamp: Date.now()
});
socket.send(payload);
}
});
// Process remote incoming mutations from co-authors
socket.onmessage = (event) => {
const data = JSON.parse(event.data);
// Execute remote mutation without triggering infinite broadcast loop
commandService.executeCommand(data.mutation.id, data.mutation.params, {
local: false
});
};
Because the command service processes operations atomically, concurrent cell edits resolve gracefully. Remote updates render onto the visual canvas layer without disturbing the active user's current cursor focus or text selection state.
Integrating AI Agents via the AG-UI Protocol
Enterprise modern application development heavily emphasizes AI automation. With AI agents shifting from simple chat windows into active workspace operations, software engineers must provide programmatic access to UI components. In early 2026, the ag-ui-protocol/ag-ui specification emerged as an open standard for connecting autonomous AI agents directly to web interfaces.
Univer's architecture exposes internal spreadsheet operations directly to external agents. Instead of forcing an AI model to analyze web screen pixel captures using vision algorithms, autonomous agents query and update document state directly through internal command channels.
"Decoupling spreadsheet state mutations from DOM presentation elements completely changes how autonomous AI agents interact with web enterprise apps. Agents can stream thousands of computed array updates per second directly into the execution engine context, completely bypassing front-end UI performance limitations."
Here is how you register a custom agent action handler using the AG-UI protocol interface inside a Univer application environment:
import { AGUIProtocolHandler } from "@ag-ui-
Comments (0)