> 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 an Event Extension

## Article: Migrate an Event Extension

## 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-an-event-extension.md

## Article Content:

# Migrate an Event Extension

This guide explains how to add an event extension 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

| Legacy | New |
|--------|-----|
| `src/backend/events/<name>/event.ts` | `src/extensions/backend/events/<name>/<name>.ts` |
| _(no config file)_ | `src/extensions/backend/events/<name>/<name>.extension.ts` |

## Step 1 | Move and rename files

To move existing files into the new project:

1. In the new project, create the folder `src/extensions/backend/events/<name>/`.
2. Copy `event.ts` from the legacy project's `src/backend/events/<name>/` folder into the new project's `src/extensions/backend/events/<name>/` folder, and rename it to `<name>.ts`.
3. In `<name>.ts`, add `export default` before the top-level handler call if it isn't already there:

```ts
// Before
myModule.onSomeEvent((event) => { ... });

// After
export default myModule.onSomeEvent((event) => { ... });
```

4. Fix any import paths in the `.ts` file if needed, including imports of backend code.

## Step 2 | Create the extension file

In `src/extensions/backend/events/<name>/`, create `<name>.extension.ts`:

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

export default extensions.event({
  id: '<generate-a-uuid>',
  source: './extensions/backend/events/<name>/<name>.ts',
});
```

| Field | Value | Required |
|-------|-------|----------|
| `id` | A new UUID. Generate 1 with `crypto.randomUUID()`. | Yes |
| `source` | Path to `<name>.ts`, relative to `src/` | Yes |

## 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 myEvent from './extensions/backend/events/<name>/<name>.extension';

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

## 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.