Skip to content

spo page clientsidewebpart add

Adds a client-side web part to a modern page

Usage

spo page clientsidewebpart add [options]

Options

Option Description
--help output usage information
-u, --webUrl <webUrl> URL of the site where the page to add the web part to is located
-n, --pageName <pageName> Name of the page to which add the web part
--standardWebPart [standardWebPart] Name of the standard web part to add (see the possible values below)
--webPartId [webPartId] ID of the custom web part to add
--webPartProperties [webPartProperties] JSON string with web part properties to set on the web part. Specify webPartProperties or webPartData but not both
--webPartData [webPartData] JSON string with web part data as retrieved from the web part maintenance mode. Specify webPartProperties or webPartData but not both
--section [section] Number of the section to which the web part should be added (1 or higher)
--column [column] Number of the column in which the web part should be added (1 or higher)
--order [order] Order of the web part in the column
-o, --output [output] Output type. json|text. Default text
--verbose Runs command with verbose logging
--debug Runs command with debug logging

Important

Before using this command, log in to a SharePoint Online site, using the spo login command.

Remarks

To add a client-side web part to a modern page, you have to first log in to a SharePoint site using the spo login command, eg. spo login https://contoso.sharepoint.com.

If the specified pageName doesn't refer to an existing modern page, you will get a File doesn't exists error.

To add a standard web part to the page, specify one of the following values: ContentRollup, BingMap, ContentEmbed, DocumentEmbed, Image, ImageGallery, LinkPreview, NewsFeed, NewsReel, PowerBIReportEmbed, QuickChart, SiteActivity, VideoEmbed, YammerEmbed, Events, GroupCalendar, Hero, List, PageTitle, People, QuickLinks, CustomMessageRegion, Divider, MicrosoftForms, Spacer.

When specifying the JSON string with web part properties on Windows, you have to escape double quotes in a specific way. Considering the following value for the webPartProperties option: {"Foo":"Bar"}, you should specify the value as `"{""Foo"":""Bar""}"`. In addition, when using PowerShell, you should use the --% argument.

Examples

Add the standard Bing Map web part to a modern page in the first available location on the page

spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart BingMap

Add the standard Bing Map web part to a modern page in the third column of the second section

spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart BingMap --section 2 --column 3

Add a custom web part to the modern page

spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --webPartId 3ede60d3-dc2c-438b-b5bf-cc40bb2351e1

Using PowerShell, add the standard Bing Map web part with the specific properties to a modern page

o365 --% spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart BingMap --webPartProperties `"{""Title"":""Foo location""}"`

Using Windows command line, add the standard Bing Map web part with the specific properties to a modern page

o365 spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart BingMap --webPartProperties `"{""Title"":""Foo location""}"`

Add the standard Image web part with the preconfigured image

spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart Image --webPartData '`{ "dataVersion": "1.8", "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{"captionText":""},"imageSources":{"imageSource":"/sites/team-a/SiteAssets/work-life-balance.png"},"links":{}}, "properties": {"imageSourceType":2,"altText":"a group of people on a beach","overlayText":"Work life balance","fileName":"48146-OFF12_Justice_01.png","siteId":"27664b85-067d-4be9-a7d7-89b2e804d09f","webId":"a7664b85-067d-4be9-a7d7-89b2e804d09f","listId":"37664b85-067d-4be9-a7d7-89b2e804d09f","uniqueId":"67664b85-067d-4be9-a7d7-89b2e804d09f","imgWidth":650,"imgHeight":433,"fixAspectRatio":false,"isOverlayTextEnabled":true}}`'