> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Migrate Service Plugin Extensions

## Article: Migrate Service Plugin Extensions

## Article Link: https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/migrate-an-app-from-legacy-cli/migrate-service-plugin-extensions.md

## Article Content:

# Migrate Service Plugin Extensions

This guide explains how to add service plugin extensions to your new Wix CLI project as part of [migrating an app from the legacy Wix CLI](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/about-the-wix-cli.md).

## Folder structure

All service plugins follow the same pattern. The `-cli/` wrapper directory is removed in the new structure:

| Legacy | New |
|--------|-----|
| `src/backend/service-plugins/<type>/<type>-cli/plugin.ts` | `src/extensions/backend/service-plugins/<type>/plugin.ts` |
| `src/backend/service-plugins/<type>/<type>-cli/plugin.json` | `src/extensions/backend/service-plugins/<type>/<type>.extension.ts` |

## Step 1 | Move files

1. In the new project, create the folder `src/extensions/backend/service-plugins/<type>/`.
2. From the legacy project, copy `src/backend/service-plugins/<type>/<type>-cli/plugin.ts` to `src/extensions/backend/service-plugins/<type>/plugin.ts` in the new project.
3. Fix any import paths in the `plugin.ts` file if needed, including imports of backend code.

Don't copy the old `plugin.json` file. It is replaced by a new `.extension.ts` file.

## Step 2 | Create the extension file

All service plugins use the same basic structure:

```ts
import { extensions } from '@wix/astro/builders';

export default extensions.<builderName>({
  id: '<id-from-plugin.json>',
  source: './extensions/backend/service-plugins/<type>/plugin.ts',
});
```

| Field | Source | Required |
|-------|--------|----------|
| `id` | `id` from `plugin.json` | Yes. Must match legacy value to preserve the extension. |
| `source` | Path to `plugin.ts`, relative to `src/` | Yes |

<blockquote class="important">

__Important:__
The `id` must match the value from the legacy `plugin.json`. Otherwise, the new entry is treated as a separate extension instead of a continuation of the legacy one.

</blockquote>

Use the builder name from the table below. Most service plugins only need `id` and `source`. The `ecom-shipping-rates` service plugin supports additional optional fields.

### Builder names and fields

| Legacy type | Builder | Additional optional fields |
|-------------|---------|---------------------------|
| `ecom-shipping-rates` | `ecomShippingRates` | `description`, `fallbackDefinitionMandatory`, `learnMoreUrl`, `dashboardUrl`, `thumbnailUrl` |
| `ecom-gift-cards` | `ecomGiftCards` | none |
| `ecom-discount-triggers` | `ecomDiscountTriggers` | none |
| `ecom-payment-settings` | `ecomPaymentSettings` | none |
| `ecom-validations` | `ecomValidations` | none |
| `ecom-additional-fees` | `ecomAdditionalFees` | none |
| `bookings-staff-sorting-provider` | `bookingsStaffSortingProvider` | none |
| `realtime-permissions-provider` | `realtimePermissionsProvider` | none |
| `viewer-service` | `viewerService` | none |
| `data-collections` | `dataCollections` | none |
| `generic-extension` | `genericExtension` | none |

### ecom-shipping-rates with optional fields

```ts
import { extensions } from '@wix/astro/builders';

export default extensions.ecomShippingRates({
  id: '<id-from-plugin.json>',
  description: '<description-from-plugin.json>',
  fallbackDefinitionMandatory: false,
  learnMoreUrl: '<learnMoreUrl-from-plugin.json>',
  dashboardUrl: '<dashboardUrl-from-plugin.json>',
  thumbnailUrl: '<thumbnailUrl-from-plugin.json>',
  source: './extensions/backend/service-plugins/ecom-shipping-rates/plugin.ts',
});
```

## Step 3 | Register the extension

In the new project, in `src/extensions.ts`, import the extension and add it with `.use()`:

```ts
import { app } from '@wix/astro/builders';
import myServicePlugin from './extensions/backend/service-plugins/<type>/<type>.extension';

export default app().use(myServicePlugin);
```

## Step 4 | Return to the main migration guide

Return to the [Test, build, and release](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/about-the-wix-cli.md#test-build-and-release) step in the main migration guide.