JavaScript API
Control the Mimeeq configurator from your own code and add custom logic. Learn how to run a headless canvas and drive rules with external values like quantity.
Mimeeq supports the ability for clients to extend our configurator logic using custom JavaScript. Below, you'll find practical examples along with code snippets to guide you through the process.
Example 1: headless canvas
Mimeeq's configurator can be used in a fully or partially headless capacity. This allows you to hide our options panel and integrate your own, while controlling our canvas with simple JavaScript commands.
Practical example
Imagine you have a sofa that comes in 10 fabrics and 5 wood leg finishes. In Mimeeq, the option block code for fabrics is called SeatFinishes, and the code for the fabric is AM003. In this scenario, you would use the following JavaScript command to mark the option block and code:
await mimeeqApp.actions.markOptionByBlockNameAndOptionCode('SeatFinishes', 'AM003');For more code examples and for selecting multiple options, check out our developer documentation.


Example 2: extend rules logic using external values such as quantity
In this example, if the quantity is 10 or more, the customer can pick a custom paint colour for the legs of the armchair. If the quantity is less than 10, they can choose from only one of five predefined options.
Set up the hidden option block
Create an option block called "Hidden JS Qty Control" in the Mimeeq app. The name can be anything you like.
Add two options to choose from, with any names and codes you prefer. In this example, I use "Show" and "Hide".
Toggle the Hide on specification option to ensure this block will be hidden from cart specifications, including Mimeeq's Basket.
Name the block something unique and easy to recognise, such as "qty10".
Use these two options as triggers to set up your rules. For more information on rules, refer to Rules Overview.
When Show is selected, the colour picker will be displayed, a material override action will be implemented, and a message widget will inform the customer about this new option.
When Hide is selected, a different message will be displayed, the colour picker will not be shown, and the standard option will be maintained.

Add the JavaScript code
The code below listens for quantity change events. If the quantity is greater than or equal to 10, it selects the "show" option using the command from Example 1. If the quantity is less than 10, it selects the "hide" option.
Try it
Here is a working example to try. Change the quantity to 10 and then back to 9.
Watch the video explanation:
Related articles
Was this helpful?