GuidesUniver SheetsGet StartedRun Univer on Node.js

Run Univer on Node.js

Univer’s isomorphic nature allows it to run not only in the browser, but also on Node.js πŸŽ‰. You can develop data processing services based on Univer on Node, generate spreadsheets on the server side, or perform operations such as formulas and pivot tables on spreadsheets, and interact with Univer through the familiar Facade API, all of which only require adjusting the loaded plugins.

Presets

If you use Presets to load Univer on Node, you can refer to the following code:

import { createUniver, LocaleType } from '@univerjs/presets';
import { UniverSheetsNodeCorePreset } from '@univerjs/presets/preset-sheets-node-core';
import sheetsNodeCoreEnUS from '@univerjs/presets/preset-sheets-node-core/locales/en-US';
 
async function run(): Promise<void> {
  const { univerAPI } = createUniver({
    locale: LocaleType.EN_US,
      locales: {
        enUS: Tools.deepMerge(
          {},
          sheetsNodeCoreEnUS,
        ),
      },
    presets: [
      UniverSheetsNodeCorePreset(),
    ],
  });
}
 
run();
Loading...

Piecemeal Installation

You can refer to the following code to start Univer on Node:

import { Univer, FUniver } from '@univerjs/core';
import { UniverDataValidationPlugin } from '@univerjs/data-validation';
import { UniverDocsPlugin } from '@univerjs/docs';
import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing';
import { UniverDrawingPlugin } from '@univerjs/drawing';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRPCNodeMainPlugin } from '@univerjs/rpc-node';
import { UniverSheetsPlugin } from '@univerjs/sheets';
import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';
import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';
import { UniverSheetsDrawingPlugin } from '@univerjs/sheets-drawing';
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
import { UniverSheetsHyperLinkPlugin } from '@univerjs/sheets-hyper-link';
import { UniverSheetsSortPlugin } from '@univerjs/sheets-sort';
import { UniverThreadCommentPlugin } from '@univerjs/thread-comment';
 
import '@univerjs/sheets/facade';
import '@univerjs/sheets-data-validation/facade';
import '@univerjs/engine-formula/facade';
import '@univerjs/sheets-filter/facade';
import '@univerjs/sheets-formula/facade';
 
export function createUniverOnNode(): Univer {
  const univer = new Univer();
 
  registerBasicPlugins(univer);
  registerSharedPlugins(univer);
  registerRPCPlugin(univer);
  registerDocPlugins(univer);
  registerSheetPlugins(univer);
 
  return univer;
}
 
function registerBasicPlugins(univer: Univer): void {
  univer.registerPlugin(UniverFormulaEnginePlugin);
}
 
function registerSharedPlugins(univer: Univer): void {
  univer.registerPlugin(UniverThreadCommentPlugin);
  univer.registerPlugin(UniverDrawingPlugin);
}
 
function registerDocPlugins(univer: Univer): void {
  univer.registerPlugin(UniverDocsPlugin);
  univer.registerPlugin(UniverDocsDrawingPlugin);
}
 
function registerSheetPlugins(univer: Univer): void {
  univer.registerPlugin(UniverSheetsPlugin);
  univer.registerPlugin(UniverSheetsFormulaPlugin);
  univer.registerPlugin(UniverSheetsConditionalFormattingPlugin);
  univer.registerPlugin(UniverDataValidationPlugin);
  univer.registerPlugin(UniverSheetsDataValidationPlugin);
  univer.registerPlugin(UniverSheetsFilterPlugin);
  univer.registerPlugin(UniverSheetsHyperLinkPlugin);
  univer.registerPlugin(UniverSheetsDrawingPlugin);
  univer.registerPlugin(UniverSheetsSortPlugin);
}
 
async function run(): Promise<void> {
  const univerAPI = FUniver.newAPI(createUniverOnNode());
}
 
run();

As you can see, Univer on Node is basically a Univer that removes UI-related plugins!