Many Wix APIs include events that trigger when specific conditions are met. Backend events allow you to respond to actions that occur on a site, enabling you to build reactive, event-driven functionality.
Backend events run on Wix's servers and execute automatically when triggered, regardless of whether visitors are actively browsing your site.
Backend event handlers can respond to events such as:
Note: Backend events are only triggered for published sites and don't work in preview mode.
Note: Backend events currently require Velo APIs and file naming conventions. While you can use the JavaScript SDK alongside Velo, backend event handlers must be defined using Velo syntax in the events.js backend file. Don't use the event handers in the JavaScript SDK for backend events when developing Wix sites.
You can define backend event handlers using:
While backend event handlers themselves must use Velo syntax, you can call SDK functions from inside your event handlers. This hybrid approach combines the event-driven architecture of backend events with the modern APIs of the JavaScript SDK.
This approach allows you to leverage both the event-driven architecture of backend events and the modern SDK APIs for data manipulation and business logic.
To test an event handler in preview mode, use functional testing. Functional testing saves you time and effort when building your own system for triggering and testing your backend functions, by allowing you to quickly test backend functions directly in the code editor.
See step-by-step instructions on how to test your backend code.
Some Velo packages include backend events, which are contained in their own events.js files. If you add a Velo package that includes backend events, you might end up with multiple events.js files in several locations.