Skip to main content
The Mage SDK is injected into the storefront at runtime via window.MageSDK. Since it isn’t an npm package, TypeScript won’t know about it by default. You can add full type support by creating a declaration file in your project.

Setup

Create a file called mage-sdk.d.ts anywhere in your project (e.g. the root, or a types/ folder):
mage-sdk.d.ts
Make sure the file is included in your tsconfig.json (it will be automatically if it’s inside your project root or include paths).

Usage

Once the declaration file is in place, you get full autocomplete and type checking: