Backend modules in the Wix JavaScript SDK give you access to Wix business solutions and platform services. You can use these modules to interact with Wix features, manage site data, process business logic, and integrate with external services. Unlike frontend modules, which only run in the browser on Wix-hosted sites, backend modules are universal and can be used in both Wix-hosted and headless environments, and can be called from backend or frontend code.
Use backend modules for:
In Wix-hosted environments such as Wix sites and apps built with the Wix CLI, you can import and call backend modules directly in your backend code. The Wix platform handles authentication automatically.
In headless and self-hosted environments, you need to create a Wix Client with an authentication strategy before using backend modules. Common authentication strategies include OAuth for user authentication, API keys for server-to-server calls, and app credentials for Wix apps.
Some backend module methods are restricted by identity type. Depending on the function, you may need to authenticate as a site visitor, site member, Wix user, or Wix app. Some methods require elevated permissions, which you can grant using the auth.elevate() method in your backend code.
For example, addToCurrentCart() can only be called when authenticated as a site visitor. If you need to add items to a cart from backend code that isn't running in a visitor's context, you need to use elevation. Similarly, createProduct() requires Wix user authentication, since only site owners or collaborators with the appropriate permissions should create products. If you need to create products from code that isn't authenticated as a Wix user, you would use elevation.