Install the Web SDK using the NPM package

Adobe Experience Platform Web SDK is available as an NPM package. Installing the NPM package allows you to have control of the build process for the Adobe Experience Platform Web SDK JavaScript library. The NPM package exposes EcmaScript version 5 modules or EcmaScript version 2015 (ES6) modules meant to be run in the browser.

npm install @adobe/alloy

The NPM package of the Adobe Experience Platform Web SDK exposes a createInstance function. The name option passed to the function controls the prefix used in logging. Below are examples of using the package.

Using the package as an ECMAScript 2015 (ES6) module

import { createInstance } from "@adobe/alloy";
const alloy = createInstance({ name: "alloy" });
alloy("config", { ... });
alloy("sendEvent", { ... });
NOTE
The NPM package relies on CommonJS modules; therefore, when using a bundler, make sure that the bundler supports CommonJS modules. Some bundlers, such as Rollup, require a plugin that provides CommonJS support.

Using the package as an ECMAScript 5 module

var alloyLibrary = require("@adobe/alloy");
var alloy = alloyLibrary.createInstance({ name: "alloy" });
alloy("config", { ... });
alloy("sendEvent", { ... });
recommendation-more-help
ad108910-6329-42f1-aa1d-5920a2b13636