Installation
By default, Alokai integration for Amplience is meant to be used as a Storefront module. However, it can also be installed in any Next or Nuxt application.
Requirements
- Server Middleware application (latest version),
- Amplience environment,
- Node.js version
18.x
, - @vsf-enterprise NPM registry access.
If you don't have an Amplience space yet, we suggest you request a demo from the Amplience team.
Installing dependencies
In your frontend application, install the following dependencies:
yarn add @vsf-enterprise/amplience-sdk
In your Server Middleware application, install the following dependencies:
yarn add @vsf-enterprise/amplience-api
Adding environment varialbes
In the .env
file of your Server Middleware application, add the following envioronment variables:
AMPL_HUB_NAME=<YOUR_AMPL_HUB_NAME>
AMPL_STAGING_ENV=<YOUR_AMPL_STAGING_ENV>
Read the Amplience docs to find out where to get your hubName and stagingEnvironment.
Configuring Server Middleware
The next step is configuring the Amplience integration in the Server Middleware.
Key concept - Server Middleware
Middleware concept is described in detail in our Key concepts: Server Middleware docs.
Add the following configuration to your Server Middleware configuration file.
import type { MiddlewareConfig as AmplienceMiddlewareConfig } from "@vsf-enterprise/amplience-api";
import type { Integration } from "@vue-storefront/middleware";
const { AMPL_HUB_NAME, AMPL_STAGING_ENV } = process.env;
if (!AMPL_HUB_NAME) throw new Error("Missing env var: AMPL_HUB_NAME");
if (!AMPL_STAGING_ENV) throw new Error("Missing env var: AMPL_STAGING_ENV");
export default {
integrations: {
amplience: {
location: "@vsf-enterprise/amplience-api/server",
configuration: {
hubName: AMPL_HUB_NAME,
stagingEnvironment: AMPL_STAGING_ENV,
unified: {
resolvePages: () => ({
"/*": {},
}),
resolveFallbackPage: () => ({
path: "fallback-page",
}),
},
},
} satisfies Integration<AmplienceMiddlewareConfig>,
},
};
Configuring Alokai SDK
The last step in the process is configuring Alokai SDK for Amplience in your frontend application.
Key concept - SDK
SDK core is described in detail in our SDK docs.
Add the following configuration to your Alokai SDK configuration file:
import { amplienceModule } from '@vsf-enterprise/amplience-sdk';
export function getSdkConfig() {
return defineSdkConfig(({ buildModule, config }) => ({
amplience: buildModule(amplienceModule, {
apiUrl: `${config.middlewareUrl}/amplience`
}),
}));
}