Docs
backend/extensions

Extensions

Extensions are simple custom modules, that you can plugin into Storecraft, to

  • Encapsulate Event based logic
  • Optionally expose Actions, that are invoked by http requests

Quick Example

Here is a simple extension for sending Slack notifications,

class SendSlackMessageExtension implements extension {
get info() {
return {
name: 'My Extension'
}
}
onInit = (app: App) => {
app.pubsub.on(
'orders/checkout/complete',
async (event) => {
const total = event.payload.pricing.total;
if(total > 100) {
await slackApi.send(
`๐Ÿ’ธ New Order, total is ${total}, ID is ${event.payload.id}`
)
}
}
)
};
}

Then, plug it in Storecraft

const app = new App(config)
.withPlatform(new NodePlatform())
.withDatabase(new MongoDB())
.withStorage(new GoogleStorage())
.withExtensions(
{
'my-slack-extension': new SendSlackMessageExtension()
}
).init();

Invoke Action with HTTP REST API

POST
/api/extensions/{extension-handle}/{action-handle}

Consult The REST API Docs

All Rights Reserved, storecraft, (2025)