This page describes how to configure the Server SDK. For the Web SDK, see Configure the Web SDK.
You configure the Server SDK with the configure method. Call it once on each instance, when your server starts and before you call forRequest or any other method. Every forRequest handle uses the configuration of the instance that created it.
The datastreamId, orgId, and edgeCredentials properties are required. All other properties are optional. The following example shows a configuration object that uses every available property:
import { createInstance } from "@adobe/alloy-node";
const alloy = createInstance();
await alloy.configure({
datastreamId: "ebebf826-a01f-4458-8cec-ef61de241c93",
orgId: "ADB3LETTERSANDNUMBERS@AdobeOrg",
edgeCredentials: {
clientId: process.env.ADOBE_CLIENT_ID,
clientSecret: process.env.ADOBE_CLIENT_SECRET,
scopes: process.env.ADOBE_SCOPES.split(",")
},
debugEnabled: false,
defaultConsent: "in",
edgeBasePath: "ee",
edgeConfigOverrides: {
com_adobe_target: {
propertyToken: "01dbc634-07c1-d8f9-ca69-b489a5ac5e94"
}
},
edgeDomain: "data.example.com",
idMigrationEnabled: false,
onBeforeEventSend: (content) => {
content.xdm.application ??= {};
content.xdm.application.name = "Example storefront";
},
thirdPartyCookiesEnabled: false
});
Configuration properties properties
The defaultConsent property is available only when the instance includes the Consent component, which createInstance includes by default. See Create a custom instance.
Options that the Server SDK doesn’t support unsupported
The Web SDK has configuration options for features that depend on a browser, such as link click collection, rendering personalized content, and push notifications. The Server SDK doesn’t accept these options. If you include one, configure rejects with an Unknown field error that names the option.
The following Web SDK options are not available: autoCollectPropositionInteractions, clickCollection, clickCollectionEnabled, context, conversation, downloadLinkQualifier, onBeforeLinkClickSend, personalizationStorageEnabled, prehidingStyle, pushNotifications, streamingMedia, and targetMigrationEnabled.
Result and errors result
The configure method returns a promise that resolves with an empty object when configuration succeeds. It rejects in the following cases:
edgeCredentialsis missing, or one of its required properties is missing.defaultConsentis set to"pending". SeedefaultConsent.- A property has an invalid value or isn’t recognized.
configurewas already called successfully on the same instance. Each instance can be configured only once.
If configure rejects, the instance stays unconfigured, and forRequest throws an error until a call to configure succeeds.