Authenticate using the Wix Client in Custom Elements for Self-Hosted Site Extensions

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

Create a client

You need 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 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?