Extending BCMS Events

BCMS Events are JavaScript functions that get triggered by events inside BCMS. They allow you to run some custom code when a specific event happens.

Creating an event handler

To create an event handler, create a file inside src/events, for example, test.ts. To keep is simple, this event will only log data which it receives:


import { createBcmsEvent } from '@becomes/cms-backend/src/event';
import {
} from '@becomes/cms-backend/src/types';

export default createBcmsEvent(async () => {
  return {
    config: {
      scope: BCMSEventConfigScope.ENTRY,
      method: BCMSEventConfigMethod.ADD,
    async handler(data) {

The event handler you created will trigger every time a new Entry is added to the database.

Triggering an event

Only Functions, Jobs, and Plugins can trigger internal events. Events are triggered using the Event Manager. A few examples:

// Trigger Entry Added event
await BCMSEventManager.emit(
    // Entry data

// Trigger Template Updated event
await BCMSEventManager.emit(
    // Template data

// Trigger custom event
await BCMSEventManager.emit(
    custom: 'data',

Deploying an event

When you are ready to deploy your event to the CMS, follow these steps:

  • Inside the project, run npm run bundle. This will compile TypeScript files and bootstrap the project.
  • Then, to deploy your event, run npm run deploy.