Others

How to Add Custom Code to Viva Connections or SharePoint

Nimra MalikNimra Malik Oct 28, 2026 870 views

Question details

The user needs to know how to add custom functionality, such as HTML or JavaScript widgets, to Microsoft Viva Connections or a modern SharePoint site.

How to Add Custom Code to Viva Connections or SharePoint
Product
Microsoft SharePoint / Viva Connections
Device & OS
not provided
Scenario
Customizing modern SharePoint sites or Viva Connections pages with custom code or external widgets.
Observed behavior
Modern SharePoint and Viva Connections restrict arbitrary HTML and JavaScript from running directly on the page, requiring a specific deployment method.
Before you start

Ensure you have the necessary administrative permissions to deploy apps to your organization's SharePoint App Catalog, and verify that your development environment is set up for SharePoint Framework (SPFx).

Solution 1Recommended

Create and Deploy an SPFx Client-Side Web Part

To bypass the restrictions on raw HTML and JavaScript, you must package your custom code as a secure client-side web part using the SharePoint Framework (SPFx).

Viva Connections and modern SharePoint sites prioritize strict security and high performance. Because of this, they do not allow arbitrary HTML or JavaScript widgets (like the classic Script Editor) to be embedded directly onto pages.

Instead, Microsoft mandates that all custom functionality be developed and packaged using the SharePoint Framework (SPFx). This ensures the code runs contextually, securely, and responsively across all devices.

1
Set up your development environment

Install Node.js, a code editor like Visual Studio Code, and the Yeoman SharePoint generator to prepare your system for SPFx development.

2
Create a new SPFx web part project

Run the Yeoman generator in your terminal to scaffold a new client-side web part project. Select the framework of your choice (e.g., React, plain JavaScript).

3
Write your custom code

Embed your HTML, JavaScript, and CSS within the web part's render methods, ensuring it complies with SPFx guidelines.

4
Package the solution

Run the appropriate gulp commands to bundle and package your solution into an .sppkg file.

5
Deploy to the App Catalog

Upload your generated .sppkg file to your organization's SharePoint App Catalog. Once deployed, you can add the web part to your Viva Connections or SharePoint pages.

Create and Deploy an SPFx Client-Side Web Part
Need Development Assistance?: For specific coding guidance, consult the official Microsoft SPFx documentation or post your question in Microsoft Q&A using the 'SharePoint development' tag.
Free Microsoft Office alternative

Boost Your Document Productivity with WPS Office

While SharePoint and Viva Connections manage your organization's intranet, you need a reliable suite to create the documents hosted there. WPS Office provides a free, lightweight, and robust alternative to Microsoft Office, ensuring seamless document creation and editing.

  1. 1. Download the Installer: Visit the official WPS website and download the free WPS Office installation package for your operating system.
  2. 2. Install WPS Office: Run the downloaded file and follow the brief on-screen instructions to complete the setup.
  3. 3. Edit Your Documents Seamlessly: Open your existing Microsoft Office files directly in WPS Office to edit them with full formatting preservation.
Highly compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx)Lightweight installation with exceptionally fast startup speedsFamiliar, intuitive user interface for a zero-learning-curve migrationBuilt-in PDF editing and conversion tools for comprehensive document management
microsoft office alternative - wps office

Frequently Asked Questions

Can I embed raw HTML or JavaScript directly into Viva Connections?

No, Viva Connections and modern SharePoint sites restrict arbitrary HTML and JavaScript from running directly on the page for security and performance reasons. You must package the code securely using the SharePoint Framework (SPFx).

Can I still use the Script Editor web part in modern SharePoint?

The classic Script Editor web part is not supported in modern SharePoint out of the box. While the community has created modern script editor web parts using SPFx, deploying custom SPFx code is the officially supported and secure approach.

Where do I deploy my custom SPFx web part?

Once your SPFx project is bundled and packaged, the resulting .sppkg file must be uploaded and deployed to your organization's SharePoint App Catalog by an administrator. From there, it can be added to individual site pages.