This example demonstrates real-time collaborative editing in the Syncfusion React Spreadsheet. Multiple users can edit the same workbook simultaneously, and the changes are synchronized through the Collaboration Server.
Before running the React client, ensure that the following software and services are available:
- Node.js
- Redis Server
- ASP.NET Core Redis Collaboration Server
The Collaboration Server and Redis Server must be running before starting the React application.
Navigate to the React client folder:
cd client/reactInstall the required dependencies:
npm installThe @syncfusion/ej2-collaborator package is listed separately because the React Spreadsheet package does not install the collaboration client automatically.
The @microsoft/signalr package is required by the collaboration client for SignalR communication with the ASP.NET Core Collaboration Server.
Open src/App.tsx and update the following URL when required:
const serviceUrl: string =
''YOUR_COLLABORATION_SERVER_URL'';The URL must point to the running ASP.NET Core Collaboration Server.
Start the React development server:
npm run devOpen the URL displayed by Vite. The default URL is:
http://localhost:5173/
When the application is opened without an id query parameter, the React client automatically generates a room name and adds it to the URL.
For example:
http://localhost:5173/?id=room-name
Copy the complete URL and open it in another browser window or tab. Clients using the same room ID collaborate on the same workbook.
The sample uses the following participant name:
const currentUser: string = 'John Adams';- The Spreadsheet is initialized with collaborative editing enabled.
- The
CollaborativeEditingHandlerservice is injected into the Spreadsheet. - The client obtains or generates a room name from the URL.
SpreadsheetEditorAdapter.loadFromServerimports the latest workbook and room version from the server.CollaborationClientconnects to the server using SignalR.- The client joins the collaboration room by calling
joinRoomAsync. - Local Spreadsheet actions are sent to the server from the
actionCompleteevent. - Remote actions received through the collaboration client are applied to the Spreadsheet.
The Syncfusion Tailwind 3 theme is imported in src/App.css:
@import "@syncfusion/ej2-tailwind3-theme/styles/tailwind3.css";The stylesheet is loaded in src/App.tsx:
import './App.css';Do not remove the App.css import. Without the theme stylesheet, the Spreadsheet output will not render correctly.
client/react/
|-- src/
| |-- App.css
| |-- App.tsx
| |-- main.tsx
| `-- SpreadsheetEditorAdapter.ts
|-- index.html
|-- package.json
|-- README.md
|-- tsconfig.app.json
|-- tsconfig.json
|-- tsconfig.node.json
`-- vite.config.ts
Create a production build by running:
npm run buildPreview the production build locally:
npm run previewEnsure @syncfusion/ej2-collaborator is present in package.json, and then run:
npm installEnsure @microsoft/signalr is present in package.json, and then run:
npm installConfirm that src/App.tsx contains:
import './App.css';Also confirm that src/App.css contains:
@import "@syncfusion/ej2-tailwind3-theme/styles/tailwind3.css";Verify the following items:
- Redis Server is running.
- The ASP.NET Core Collaboration Server is running.
- The
serviceUrlvalue points to the correct server. - All clients use the same room ID in the URL.
- The browser console does not contain SignalR connection or CORS errors.
This project is licensed under the terms provided in the repository license file.