Create modern team site in SPFx












4















I found some articles which are explaining creating modern sites with CSOM. But I am not able to find in JavaScript to use in SPFx.
Creating modern sites is supported with SPFx? Any PnP extension available for this?










share|improve this question





























    4















    I found some articles which are explaining creating modern sites with CSOM. But I am not able to find in JavaScript to use in SPFx.
    Creating modern sites is supported with SPFx? Any PnP extension available for this?










    share|improve this question



























      4












      4








      4


      1






      I found some articles which are explaining creating modern sites with CSOM. But I am not able to find in JavaScript to use in SPFx.
      Creating modern sites is supported with SPFx? Any PnP extension available for this?










      share|improve this question
















      I found some articles which are explaining creating modern sites with CSOM. But I am not able to find in JavaScript to use in SPFx.
      Creating modern sites is supported with SPFx? Any PnP extension available for this?







      sharepoint-online javascript spfx spfx-webparts modern-experience






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 7 '18 at 12:35









      Gautam Sheth

      24.1k12048




      24.1k12048










      asked Dec 7 '18 at 12:27









      MihirMihir

      75351942




      75351942






















          2 Answers
          2






          active

          oldest

          votes


















          7














          You can use the PnPJS to create modern team and communication sites.



          For that, simply add the below packages:



          npm install @pnp/logging @pnp/common @pnp/odata @pnp/sp --save


          After that, you can add the below import statement:



          import { sp } from "@pnp/sp";


          And in the webpart, you can use it as below to create modern sites:



          1) Modern communication sites:



          sp.site.createCommunicationSite(
          "Comm Site Title",
          1033,
          true,
          "https://tenant.sharepoint.com/sites/commSite",
          ).then(d => {
          console.log(d);
          });


          2) Modern team site:



          sp.site.createModernTeamSite(
          "displayName",
          "alias",
          true,
          1033,
          "description",
          "",
          ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
          .then(d => {
          console.log(d);
          });


          Reference - PnPJS Sites






          share|improve this answer



















          • 1





            I don't see the point to have two identical answers.. so deleted mine despite I answered a bit earlier than you...

            – Sergei Sergeev
            Dec 7 '18 at 14:52



















          5














          You can do that with the most recent version (1.2.6) of PnPjs library:



          import { sp } from "@pnp/sp";

          sp.site.createModernTeamSite(
          "displayName",
          "alias",
          true,
          1033,
          "description",
          "HBI",
          ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
          .then(d => {
          console.log(d);
          });





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "232"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsharepoint.stackexchange.com%2fquestions%2f253918%2fcreate-modern-team-site-in-spfx%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            7














            You can use the PnPJS to create modern team and communication sites.



            For that, simply add the below packages:



            npm install @pnp/logging @pnp/common @pnp/odata @pnp/sp --save


            After that, you can add the below import statement:



            import { sp } from "@pnp/sp";


            And in the webpart, you can use it as below to create modern sites:



            1) Modern communication sites:



            sp.site.createCommunicationSite(
            "Comm Site Title",
            1033,
            true,
            "https://tenant.sharepoint.com/sites/commSite",
            ).then(d => {
            console.log(d);
            });


            2) Modern team site:



            sp.site.createModernTeamSite(
            "displayName",
            "alias",
            true,
            1033,
            "description",
            "",
            ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
            .then(d => {
            console.log(d);
            });


            Reference - PnPJS Sites






            share|improve this answer



















            • 1





              I don't see the point to have two identical answers.. so deleted mine despite I answered a bit earlier than you...

              – Sergei Sergeev
              Dec 7 '18 at 14:52
















            7














            You can use the PnPJS to create modern team and communication sites.



            For that, simply add the below packages:



            npm install @pnp/logging @pnp/common @pnp/odata @pnp/sp --save


            After that, you can add the below import statement:



            import { sp } from "@pnp/sp";


            And in the webpart, you can use it as below to create modern sites:



            1) Modern communication sites:



            sp.site.createCommunicationSite(
            "Comm Site Title",
            1033,
            true,
            "https://tenant.sharepoint.com/sites/commSite",
            ).then(d => {
            console.log(d);
            });


            2) Modern team site:



            sp.site.createModernTeamSite(
            "displayName",
            "alias",
            true,
            1033,
            "description",
            "",
            ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
            .then(d => {
            console.log(d);
            });


            Reference - PnPJS Sites






            share|improve this answer



















            • 1





              I don't see the point to have two identical answers.. so deleted mine despite I answered a bit earlier than you...

              – Sergei Sergeev
              Dec 7 '18 at 14:52














            7












            7








            7







            You can use the PnPJS to create modern team and communication sites.



            For that, simply add the below packages:



            npm install @pnp/logging @pnp/common @pnp/odata @pnp/sp --save


            After that, you can add the below import statement:



            import { sp } from "@pnp/sp";


            And in the webpart, you can use it as below to create modern sites:



            1) Modern communication sites:



            sp.site.createCommunicationSite(
            "Comm Site Title",
            1033,
            true,
            "https://tenant.sharepoint.com/sites/commSite",
            ).then(d => {
            console.log(d);
            });


            2) Modern team site:



            sp.site.createModernTeamSite(
            "displayName",
            "alias",
            true,
            1033,
            "description",
            "",
            ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
            .then(d => {
            console.log(d);
            });


            Reference - PnPJS Sites






            share|improve this answer













            You can use the PnPJS to create modern team and communication sites.



            For that, simply add the below packages:



            npm install @pnp/logging @pnp/common @pnp/odata @pnp/sp --save


            After that, you can add the below import statement:



            import { sp } from "@pnp/sp";


            And in the webpart, you can use it as below to create modern sites:



            1) Modern communication sites:



            sp.site.createCommunicationSite(
            "Comm Site Title",
            1033,
            true,
            "https://tenant.sharepoint.com/sites/commSite",
            ).then(d => {
            console.log(d);
            });


            2) Modern team site:



            sp.site.createModernTeamSite(
            "displayName",
            "alias",
            true,
            1033,
            "description",
            "",
            ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
            .then(d => {
            console.log(d);
            });


            Reference - PnPJS Sites







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 7 '18 at 12:33









            Gautam ShethGautam Sheth

            24.1k12048




            24.1k12048








            • 1





              I don't see the point to have two identical answers.. so deleted mine despite I answered a bit earlier than you...

              – Sergei Sergeev
              Dec 7 '18 at 14:52














            • 1





              I don't see the point to have two identical answers.. so deleted mine despite I answered a bit earlier than you...

              – Sergei Sergeev
              Dec 7 '18 at 14:52








            1




            1





            I don't see the point to have two identical answers.. so deleted mine despite I answered a bit earlier than you...

            – Sergei Sergeev
            Dec 7 '18 at 14:52





            I don't see the point to have two identical answers.. so deleted mine despite I answered a bit earlier than you...

            – Sergei Sergeev
            Dec 7 '18 at 14:52













            5














            You can do that with the most recent version (1.2.6) of PnPjs library:



            import { sp } from "@pnp/sp";

            sp.site.createModernTeamSite(
            "displayName",
            "alias",
            true,
            1033,
            "description",
            "HBI",
            ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
            .then(d => {
            console.log(d);
            });





            share|improve this answer




























              5














              You can do that with the most recent version (1.2.6) of PnPjs library:



              import { sp } from "@pnp/sp";

              sp.site.createModernTeamSite(
              "displayName",
              "alias",
              true,
              1033,
              "description",
              "HBI",
              ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
              .then(d => {
              console.log(d);
              });





              share|improve this answer


























                5












                5








                5







                You can do that with the most recent version (1.2.6) of PnPjs library:



                import { sp } from "@pnp/sp";

                sp.site.createModernTeamSite(
                "displayName",
                "alias",
                true,
                1033,
                "description",
                "HBI",
                ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
                .then(d => {
                console.log(d);
                });





                share|improve this answer













                You can do that with the most recent version (1.2.6) of PnPjs library:



                import { sp } from "@pnp/sp";

                sp.site.createModernTeamSite(
                "displayName",
                "alias",
                true,
                1033,
                "description",
                "HBI",
                ["user1@tenant.onmicrosoft.com","user2@tenant.onmicrosoft.com","user3@tenant.onmicrosoft.com"])
                .then(d => {
                console.log(d);
                });






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 7 '18 at 12:31









                Sergei SergeevSergei Sergeev

                10.2k52342




                10.2k52342






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to SharePoint Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsharepoint.stackexchange.com%2fquestions%2f253918%2fcreate-modern-team-site-in-spfx%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    To store a contact into the json file from server.js file using a class in NodeJS

                    Redirect URL with Chrome Remote Debugging Android Devices

                    Dieringhausen