Build a Backend Events Extension in Studio Two

A Backend Events extension is a configuration file plus an event handler. You generate the files first, then spend most of your time in the handler.

This article walks through the handler for the Contact Created event. To add the extension, see Add a Backend Events Extension in Studio Two.

Follow the instructions below to:

  1. Scaffold the extension.
  2. Keep the configuration.
  3. Write the handler.

Step 1 | Scaffold the extension

Start from a generated extension rather than an empty folder, so the file structure and registration are already in place.

For the full procedure, see Add a Backend Events Extension in Studio Two.

You can find the new files under src/extensions/backend/events/<event-folder>/. You spend most of this article in <event-folder>.ts. For what every file in the folder is for, see Event Extension Files and Code.

Step 2 | Keep the configuration

<event-folder>.extension.ts is the configuration file. For an extension generated in the folder docs-event-check, it looks like this:

Copy

Leave the id that the Builder generated. source is the path to the handler, relative to src/.

Step 3 | Write the handler

<event-folder>.ts is the code Wix calls when the event occurs. The Contact Created handler that writes a log entry looks like this:

Copy

event is the event object that Wix passes to the handler. Its fields depend on the event. For the payload of each event, see its page in the API Reference.

The handler can run more than once for the same event, so keep it safe to repeat. For example, avoid creating a second record each time it runs without checking whether one exists. For how events are delivered, see Events.

To listen for a different event, change the import and the handler method. For example, swap contacts.onContactCreated for another event method from the same module or another module. The available methods are in the API Reference.

Use monitoring from @wix/essentials to write log entries. console output doesn't appear in your site's logs. See Write Log Messages in Studio Two.

When the handler does what you want, click Publish in the Studio Two editor to ship the extension with your site.

See also

Last updated: 2 November 2026

Did this help?