Hooks

To allow the user to insert custom code (e.g. for navigation after page creation), the hook pattern has been introduced.

Through this pattern it is possible to register callbacks, which are then executed by the Frontend API. It can be used as follows:

import { EcomHooks } from 'fcecom-frontend-api-client';

type OpenStoreFrontUrlPayload = {
  /**
   * ID of the element to open.
   *
   */
  id: string;
  /**
   * Display name of the element to open.
   *
   */
  name: string;
  /**
   * Type of the element to open.
   *
   */
  type: string;
};

api.addHook(EcomHooks.OPEN_STOREFRONT_URL, (payload: OpenStoreFrontUrlPayload) => {
    // Custom logic
});

Please note that all callbacks will receive a single object containing the parameters. Further available hooks are documented in the enumeration EcomHooks in the Technical Reference documentation.


Last update: January 30, 2023