Exported function
Export the function from your entry file under the extension’sfunctionName in napps.config.json. See How App Extensions work. The examples on this page name it onCartChanged.
CartOperations. It is a runtime global, also available as NAPPS.CartOperations; @napps/component-extension exports its type only, so do not import it as a value. Its type is CartOperations | undefined because not every surface registers it, so check it before use. See Cart operations and Data models.
Execution behavior
- The app can call the hook repeatedly, up to three passes.
- Each pass receives the latest cart, after the previously returned operations are applied.
- The app drops conflicting operations.
- Return an empty array when no change is needed.
- Async work must complete within the extension’s three-second execution budget.