Implement Service Plugins

Implement service plugins to extend the functionality of apps created by Wix on a site.

Note: You currently can't add the service plugin feature to a site when using Git Integration & CLI, or using the SDK.

The process of implementing a service plugin has 5 steps:

  1. Creating a service plugin on a site
  2. Implementing and testing your custom code
  3. Testing the service plugin
  4. Deploying the service plugin
  5. Removing an extension

The end result is a functional service plugin that extends a site's capabilities at specific points in app flows.

For detailed instructions, see the tutorial for each available service plugin.

Step 1 | Create a service plugin on a site

This step adds a service plugin to a site and creates the necessary folder structure.

At the end of this step, you'll have a service plugin folder with template files ready for customization.

To create a service plugin on a site:

  1. If necessary, add the relevant app to a site, such as Wix Stores.
  2. Go to the Public & Backend section of the Code sidebar.
  3. Hover over Service Plugins, and click the Add icon to add the integration that you want.
  4. Follow the prompts to add the plugin, and accept any terms and conditions that display.
  5. Enter a name for your integration, and click Add & Edit Code. The name can't contain spaces or special characters.

Note: If you're using the Wix IDE, your plugin appears in the /src/backend/service-plugin/<your-app-plugin-folder> folder. If your service plugin doesn't appear, try refreshing both the editor and the Wix IDE.

Step 2 | Implement your service plugin with custom code

This step involves writing the custom logic for your service plugin in the generated template files.

At the end of this step, you'll have functional code that implements your service plugin's logic.

To implement your service plugin with custom code:

  1. Locate the folder created in the previous step under Service Plugins in the Public & Backend section of the Code sidebar. The folder name is based on the plugin you chose and contains 2 files: <plugin-name>-config.js and <plugin-name>.js.

  2. Find the default extension files and implement your custom code:

    • <plugin-name>-config.js: The code in this file generally defines a method, getConfig(), that returns an object containing values used to configure your extension. Wix calls this method when you publish a site, and changes to the configuration don't take effect until you publish the site.
    • <plugin-name>.js: The code in this file generally defines a method named after the purpose of the service plugin, such as getShippingRates() or getFees(). Wix calls this method to retrieve the data provided by the service plugin.

For guidelines for writing your code, see the tutorial for each available service plugin.

Note: We recommend you use the standard export syntax contained in the code files when they're created. If you wish to use a different export syntax, for information about supported formats, see Module Export Syntax.

Step 3 | Test the service plugin

Before deploying your service plugin, test it thoroughly to ensure it works correctly and handles various scenarios. Testing prevents production issues and validates your implementation.

At the end of this step, you'll have verified that your service plugin functions as expected and handles edge cases properly.

To test your service plugin:

  1. Start with functional testing: Test your service plugin methods directly in the code editor using functional testing. This lets you verify your logic without publishing your site.

  2. Add logging for debugging: Include console.log() statements in your service plugin code to track execution flow and identify issues. After publishing, view these logs in Wix Logs.

  3. Validate method responses: Verify that your service plugin methods return properly formatted responses matching the expected schema for your specific service plugin type.

  4. Test edge cases and error handling: Ensure your code properly handles:

    • Invalid or missing input parameters
    • Network timeouts or failures (for external API calls)
    • Empty or null data scenarios
    • Large data sets or high-volume requests
  5. Verify configuration (if applicable): If your service plugin uses a config file, test that the getConfig() method returns valid configuration data.

  6. Test on a test site before production: After publishing your site once, test service plugin changes on a test site before deploying to production. Note: You must publish your production site at least once after implementing the service plugin for it to work on test sites.

Step 4 | Deploy the extension

This step publishes your service plugin to make it active on a site. At the end of this step, your service plugin is live and functional.

After your code files are ready, publish the site to deploy the service plugin extension.

Step 5 | (Optional) Remove an extension

This optional step removes a service plugin from a site if you no longer need it. At the end of this step, the service plugin is completely removed from a site.

To remove an extension:

  1. In the Public & Backend section of the Code sidebar, under Service Plugins, hover over the extension's folder and click the More Actions icon.
  2. Click Delete.

See also

Did this help?