Site API

The Site API enables you to interact with Wix sites from frontend code. Use it to build Wix Apps or extend site capabilities by accessing site-specific features like visitor consent management, site data, and secure integration with Wix business solutions such as Stores, Bookings, and SEO.

Setup

@wix/site

To use the Site API, install the @wix/site package.

Install the package

Follow the installation instructions for your development environment.

Development environmentInstallation method
Wix Studio or Wix EditorUse the package manager.
Wix VibePackage is automatically available.
CLI and self-hosted appsRun npm install @wix/site or yarn add @wix/site.

Sites

Site developers using Wix Studio, Wix Editor, or Wix Vibe can use the Site API to access features available only within a live Wix site environment, such as managing visitor consent and analytics.

Example

The following example uses the Consent Policy Manager submodule to get the site visitor's consent policy for GDPR or CCPA compliance:

Copy

Apps

Wix Apps use the Site API to access Wix APIs and site data. You can use it in both Wix-hosted and self-hosted apps, including site widgets and embedded scripts, to securely interact with the Wix site environment.

Wix-hosted Apps

For Wix-hosted apps, import one of the frontend SDK modules in your code and call its methods directly. Supported modules are listed under Frontend Modules in the menu of this SDK reference. The following example uses the seo module:

Copy

Self-hosted apps

For self-hosted apps, first create a Wix Client with the relevant frontend modules. Supported modules are listed under Frontend Modules in the menu of this SDK reference. The following example uses the seo module:

Note: To call backend modules from your frontend code, use site.auth() to authenticate your client. This requires an access token. See the authentication guides for Custom Elements and Embedded Scripts.

Copy

Note: You can find your app ID in the OAuth page of the Wix Dev Center.

Finally, use the client constant to call the frontend module's methods. For example:

Copy
Did this help?