Service Plugin Extension Files and Code

When you generate a service plugin extension, the CLI adds the following files to your project:

Service plugin builder

The <your-service-plugin>.extension.ts file contains the service plugin builder configuration. This file provides all required configuration for your plugin.

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

Copy

Here's an example builder definition for an eCommerce Shipping Rates service plugin:

Copy

Builder fields

The following fields are commonly used in the configuration object:

FieldTypeDescription
idstringService plugin ID as a (GUID). The ID is automatically generated and must be unique across all extensions in the project.
namestringThe service plugin name.
descriptionstringA short description of what the service plugin does.
sourcestringPath to the service plugin handler file that contains the plugin logic.

Additional fields may be required or optional depending on the specific service plugin type. You can find the details for each field by locating your service plugin in this table and clicking on the link to view its documentation.

Service plugin handler

The <your-service-plugin>.ts file contains the service plugin handler logic.

This file contains:

  • The relevant import statement for the service plugin.
  • Handler functions that Wix calls automatically when the relevant site action triggers them. These functions are where you add your custom logic.

The generated <your-service-plugin>.ts file will contain example code with empty placeholders for each of the functions.

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

Copy

Here's an example my-service-plugin.ts file for the eCommerce Shipping Rates service plugin:

Copy

Your custom logic should be placed inside each handler function. To find out what your function receives in the parameters and what it must return, see the documentation for your specific service plugin. Locate your service plugin in this table and click on the link to view its documentation, then navigate to the specific function in the menu.

Did this help?