Strapi is an open-source content management system that makes it possible to create various digital products. Strapi presents itself as a headless CMS – a back-end content management system for cross-platform content delivery. It comes with a modern content management interface, versatile tools and a set of plugins. Strapi’s customizable API options enable content building and collaboration on the web, mobile and desktop platforms.
To provide Strapi users with the ability to edit and collaborate on office documents online, it’s possible to integrate the Strapi content management platform with ONLYOFFICE Docs using an official integration app. ONLYOFFICE Docs is an open-source office suite that offers a free community edition and paid commercial versions for businesses and software developers.
The ONLYOFFICE package comprises web-based collaborative editors for documents, spreadsheets, presentations and fillable forms, and a viewer for PDF and DjVu files. ONLYOFFICE Docs opens and edits Word, Excel and PowerPoint files because it’s perfectly compatible with Microsoft Open Office XLM formats (DOCX, XLSX and PPTS).
ONLYOFFICE Docs comes with official integration apps for different file storage solutions, LMS solutions and DMS platforms, including Nextcloud, Seafile, Nuxeo, ownCloud, WordPress, Confluence, Alfresco, Redmine, SharePoint, Moodle, Chamilo, etc.
In this guide, we will tell you how to install and integrate Strapi with ONLYOFFICE Docs on Ubuntu to enable real-time document editing and collaboration within the Strapi content management platform.
What you’ll learn
This guide describes how to connect ONLYOFFICE Docs to the Strapi platform on Ubuntu via the official integration app developed by ONLYOFFICE to allow Strapi users to edit and collaborate on documents, spreadsheets and presentations in real time.
What you’ll need
Node.js (only LTS versions like v14 and v16);
npm (v6 only) or yarn to run the Strapi CLI installation scripts;
ONLYOFFICE Docs (Community Edition or Enterprise Edition);
ONLYOFFICE integration app for Strapi.
The easiest and fastest way to run Strapi locally is to use Strapi CLI (Command Line Interface) installation scripts. This installation method is most recommended by the Strapi developers, and even beginners won’t find it difficult.
Before installation, you need to make sure that the following software prerequisites are installed on your machine:
You also need a database for your Strapi project. Currently, you can choose from SQLite, PostgreSQL, MySQL and MariaDB. The default option for a quick start is SQLite.
To create a new Strapi project, you need to run the installation script using this command:
npx create-strapi-app@latest my-project
yarn create strapi-app my-project
Note: This is the most basic CLI installation option. However, there are other options that you might want to use. For more information, take a look at the official CLI documentation.
After that, it’s necessary to choose an installation type:
Custom (manual settings)
The former installation type uses the default SQLite database. The latter allows you to choose the preferred database.
If you prefer the custom installation type, you need to choose a database among the list of databases and name your Strapi project’s database.
Run one of these commands in the project folder so that you can open the Strapi admin panel:
npm run build
To run Strapi, execute this command in the project folder:
npm run develop
Now you can discover the features of the Strapi platform by yourself using Strapi’s user guide.
Install ONLYOFFICE Docs
To install ONLYOFFICE Docs (ONLYOFFICE Document Server), you can take a look at this guide and choose the most suitable installation way, Docker or the official Deb package.
Install the official integration app for Strapi
Now that you have a new Strapi project and an ONLYOFFICE Docs instance, you can install the official integration app. However, you need to make some changes to the
strapi/config/middlewares.js file. Replace the
strapi::security line in this file with the following lines:
"script-src": ["'self'", "https:", "http:"],
"frame-src": ["'self'", "https:", "http:"],
If this configuration already exists, you need to add
After that, it’s time to install the ONLYOFFICE plugin in your Strapi project with this command:
npm install onlyoffice-strapi --save
After the installation process is completed, you need to rebuild and restart Strapi. To do so, run the following commands:
npm run build
npm run develop
Configure the official integration app for Strapi
The final step involves the configuration of the ONLYOFFICE plugin. You can configure it via the Strapi Dashboard. Go to Settings, click Global settings and find ONLYOFFICE. On the ONLYOFFICE settings page, enter the following parameters:
- Document server address
- Document server JWT secret key
The first parameter is the URL of your ONLYOFFICE Docs (ONLYOFFICE Document Server) instance. The second parameter allows you to enable JWT protection to prevent your documents from unauthorized access. If you need this feature in ONLYOFFICE Docs, you can find more information in the official API documentation.
How to use ONLYOFFICE Docs within Strapi
The ONLYOFFICE plugin lets you view, edit and collaborate on documents, spreadsheets and presentations that are available in the Strapi Media Library. Also, all the files that are available for viewing or editing can be found and sorted out on the ONLYOFFICE files page within the Strapi platform. When you click on a file, the corresponding ONLYOFFICE editor opens it immediately.
In Strapi, there is a system of permissions that can be assigned to roles. Roles are usually associated with the users who have access to the Strapi admin panel. When it comes to ONLYOFFICE Docs, roles are also important. For example, only users with the Update (crop, details, replace) + delete permission can edit office documents. For viewing, it’s necessary to have a role with the Access the Media Library permission.