Is there a way with pnpjs to set the homepage of a site? basically what Set-PnPHomePage commandlet does

I can create a site, web, client side page, add controls to that page with pnpjs, but I cant see any way to set the homepage/Welcome page.

Any help greatly appreciated! -Powell


2 Answers 2


As per the link provided in comments above, you can use web object to update the home page (WelcomePage of the SharePoint site.

Use PnP JS code like below:

import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/folders/web";

const sp = spfi(...);

const result = await sp.web.rootFolder.update({ 
    WelcomePage: "SitePages/home.aspx" 

Documentation: @pnp/sp/webs

Payload/Properties referred from this post: Set Make Homepage - REST API


Can do it with PnP JS like so:

await sp.web.rootFolder.update({WelcomePage:"SitePages/NewHomePage.aspx"});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.