Site widgets are draggable UI components that Wix site owners can add to pages on their website. They enhance a site's functionality by displaying content or enabling site visitors to perform various tasks.
When working in the site editor, site owners can adjust the size of the widget, reposition it, and customize it using its settings panel.
Note: When viewing the widget in the site editor, the widget can't call Wix APIs.
The following example shows the Wix FAQ widget in the site editor:
When configuring a site widget, you can set it to be essential, meaning that it is crucial to your app’s functionality. Deleting an essential widget (or the section or page that contain it) from a site, will also delete the entire app. An essential widget can only be added once to a site and users cannot duplicate it.
Note: You can set a widget to be essential only if the widget is added as part of a site page extension.
You can add a site widget extension using:
Here are some factors to consider when choosing which implementation to work with:
The way to interact with a user site from your site widget extension depends on your implementation. For widgets created with Blocks, use Velo. For widgets created via the CLI, use the Site API.
When rendered in the editor, custom elements are sandboxed to enhance security. This means they're treated as if they come from a different domain, and Wix does not support the allow-same-origin
directive in the sandbox attribute. As a result, your site widget can't access same-origin resources in the editor.
This restriction impacts several key web storage and caching APIs:
document.cookie
Window.localStorage
and Window.sessionStorage
To overcome these limitations:
viewMode()
.Note: When working with cookies, make sure to comply with GDPR and data protection regulations.