I have created an SPFx web part, deployed it, and added it to a page. I want to restrict other end users' ability to add the same web part to other pages. It's not a security thing, it's a tech saavy thing. The users won't know what it is, and it will potentially just cause confusion. Is it possible for me to 'hide' it from the web parts toolbox?

I found an old thread asking the same thing, and the guidance was to restrict permissions on the relevant file in the web part gallery. That won't work in this case, as SPFx web parts are served up from the CDN (or app catalog) so they don't have a file in the web part gallery. This client is in SharePoint O365.

Thanks! :-)

  • I don't know, but could a possible temporary fix be to check something like the page name, if its always named the same. If the WebPart is added to some other page you'll just render some text explaining its not available to use the WP etc? Ofc that would only work if you have control over the code etc. – Anders Aune Jan 17 at 10:55
up vote 1 down vote accepted

There is a property in the web part manifest named hiddenFromToolbox which you can set to true to hide it from the toolbox:

{
  "$schema": "https://dev.office.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
  "id": "1c66eda5-6e12-4df6-8d67-a65dc9495197",
  "alias": "HelloWorldWebPart",
  "componentType": "WebPart",

  // The "*" signifies that the version should be taken from the package.json
  "version": "*",
  "manifestVersion": 2,

  // If true, the component can only be installed on sites where Custom Script is allowed.
  // Components that allow authors to embed arbitrary script code should set this to true.
  // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
  "requiresCustomScript": false,
  "hiddenFromToolbox": true,

  "preconfiguredEntries": [{
    "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
    "group": { "default": "Other" },
    "title": { "default": "HelloWorld" },
    "description": { "default": "HelloWorld description" },
    "officeFabricIconFontName": "Page",
    "properties": {
      "description": "HelloWorld"
    }
  }]
}

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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