Event Extension Files and Code

When you generate an event extension, the CLI adds the following files to your project:

Event builder

The <your-event>.extension.ts file contains an event extension's builder configuration.

The event builder is defined using the following schema, shown here as a TypeScript type:

Copy

Here's an example builder definition:

Copy

Builder fields

The following fields can be used in the configuration object:

FieldTypeDescription
idstringEvent extension ID as a (GUID). The ID is automatically generated and must be unique across all extensions in the project.
sourcestringPath to the event handler file that contains the event logic.

Important: You can't have 2 event extensions listening to the same event in your app. Each event can only have one handler. This includes extensions added to your app in the app dashboard, not only those in the local files for your project.

Event handler

The <your-event>.ts file contains an event extension's handler logic.

This file contains:

  • The relevant import statement for the event.
  • An event function where you can implement your custom logic. Wix calls this function when the given event occurs, passing the event object and its metadata. Event functions are documented in their module in the JavaScript SDK reference.

The generated <your-event>.ts file will contain example code for an event.

The <your-event>.ts file must be in the following format:

Copy

Here's an example my-event.ts file for the Wix CRM onContactCreated() event:

Copy
Did this help?