Authenticate Custom Elements Using the Wix Client

Tip: The self-managed framework requires you to manage deployment, authentication, and ongoing maintenance. To reduce complexity, build your site extensions with the Wix CLI.

In a custom element for a self-managed site widget or site plugin, you need to use a Wix Client to call Wix APIs using the SDK.

Create a client

You need to provide Wix with a function that injects your client with the access token:

  1. Create a client using Site host context and Site authentication.
  2. In your class component's constructor, add:
    Copy
    Wix calls this function to inject your client with an access token.

With this setup, Wix injects your client with an access token and you can use your client to call SDK methods.

Example

The following example shows a custom element that uses an authenticated client to call:

  • products.queryProducts from the @wix/stores backend module
  • seo.title from the @wix/site-seo frontend module
Copy
Did this help?