Single Part App Page In SharePoint Online

What is a Single Part App Page?

A single part app page is nothing but a SharePoint Framework web part with a locked layout. This means when you make your web part as a single part app page, then the users cannot modify the page layout using the browser.

Make your existing web part as Single Part App Page

You can choose any of your existing web parts to make it as a single part app page, but you’ll have to decide when to use it as a single part app page.
In this example, I’ll use my previous code on "Creating a single page app in SPFx" which you can find here.
Step 1
Download the zipped source code and extract files.
Single Part App Page in SharePoint Online 
Or you can also use your own web part code.
Step 2
Open the extracted folder in the code editor and navigate to the SinglePageAppWebPart.manifest.json file inside the “src” folder.
Single Part App Page in SharePoint Online 
Step 3
In the “supportedHosts”, add “SharePointFullPage”
"supportedHosts": ["SharePointWebPart", "SharePointFullPage"],
Now, your manifest.json will look like this.
  1. {  
  2.   "$schema""",  
  3.   "id""2d3e8aa0-cc9c-405e-8f74-b74c03566a06",  
  4.   "alias""SinglePageAppWebPart",  
  5.   "componentType""WebPart",  
  7.   "version""*",  
  8.   "manifestVersion": 2,  
  10.   "requiresCustomScript"false,  
  11.   "supportedHosts": ["SharePointWebPart""SharePointFullPage"],  
  13.   "preconfiguredEntries": [{  
  14.     "groupId""5c03119e-3074-46fd-976b-c60198311f70",  
  15.     "group": { "default""Other" },  
  16.     "title": { "default""SinglePageAPP" },  
  17.     "description": { "default""SinglePageAPP description" },  
  18.     "officeFabricIconFontName""Page",  
  19.     "properties": {  
  20.       "description""SinglePageAPP"  
  21.     }  
  22.   }]  
  23. }  
Step 4
Go to your package-solution.json file and change
"isDomainIsolated": false,
This is to ensure that we don’t face “Refused to execute inline script” error after deployment.
Step 5
That’s it -- build and package your solution and upload it to the app catalog in your SharePoint.
Build - “gulp bundle”
Package - “gulp package-solution --ship”
Step 6
Insert the web part on a fresh modern page of your SharePoint.
Single Part App Page in SharePoint Online 
You can see that we can still edit the page layout.
Step 7
As a final step, single part app pages will have a locked layout. Let's run a simple PowerShell command.
Open SharePoint online management shell and execute the following script.
  1. Connect-PnPOnline -Url https://<your-tenant><site-name>  
  2. $item2 = Get-PnPListItem -List "Site Pages" -Query "<View><Query><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='Text'><page-name>.aspx</Value></Eq></Where></Query></View>"  
  3. $item2["PageLayoutType"] = "SingleWebPartAppPage"  
  4. $item2.Update()  
  5. Invoke-PnPQuery  
Step 8
Refresh the page after executing the script and you should see that the page layout is no longer editable.
Single Part App Page in SharePoint Online
The Edit option above is for editing the web part properties and not the page layout.
Cool, we have created our Single Part App Page. Let’s explore much more interesting stuff on SharePoint in my future articles. 😊