Skip to content

Create a MACH component

Creating a component

The easiest way to get started with a component is by using the mach bootstrap command:

$ mach bootstrap component

This will generate a new project including a README file on how to get started and include it in your MACH configuration.

Adding it to your stack

A component can be added to your MACH stack by including it in your MACH configuration.

It should be present in your:

  1. Component definitions so that MACH knows where to find your component
  2. Site component configuration to include it in your MACH stack add site-specific configuration

The tutorial includes an example of a configuration file with a component implemented.

Using Serverless framework

The 'function'-part of a MACH component can easily be integrated with the serverless framework for "zero-friction serverless development".

This gives you a couple of features:

  • Easy local development of your function code including mocked infrastructure that might be needed for your setup
  • Build & package your function by calling sls package. More info about Packaging & Deployment

Serverless framework in your MACH deployment

Altho we do encourage the usage of the serverless framework for development and packaging, we don't recommend using it for the actual MACH deployment itself.
More info about this in the MACH configuration deployment notes.

Further reading

Continue to component structure for an explanation of a component's internals.