Version checker

The SDK provides a version checker to check the compatibility of the JavaScript SDK version and a Sitecore Content Hub instance version.

Note

In the following code examples, the client variable refers to the ContentHubClient instance. When using the JavaScript SDK, you can choose your own variable name, but it is called client at instantiation in the docs.

Check compatibility of the Content Hub instance with minimum required version

For example, the following snippet checks whether the Content Hub instance runs version 4.0.0:

RequestResponse

await client.versionChecker.compatibilityCheckAsync(new FileVersion(4, 0, 0, 0));

Warning

The call throws a NotSupportedError if the Content Hub instance does not run version 4.0.0.

Get the compatibility between a Content Hub instance and the SDK

For example, the following snippet gets compatibility between a Content Hub instance and the SDK:

RequestResponse

const compatibility = client.versionChecker.getCompatibility(
  new FileVersion(3, 0, 0),
  new FileVersion(4, 0, 0),
  new FileVersion(3, 0, 0)
);

First, we pass the FileVersion of the Content Hub , then the FileVersion of the SDK, and finally, the minimum SDK version as dictated by the Content Hub instance.

The call returns:

  • Compatibility.Ok if the Content Hub instance and the SDK are compatible.

  • Compatibility.SdkOld if the Content Hub instance has a newer version than the SDK.

  • Compatibility.SdkNew if the Content Hub instance has a older version than the SDK.

Check if a Content Hub instance is compatible with a SDK version

The following snippet checks whether a Content Hub instance is compatible with a SDK version:

RequestResponse

const isCompatible = await client.versionChecker.isCompatibleAsync(new FileVersion(1, 0, 0, 0));

The FileVersion is the version of the SDK.

Do you have some feedback for us?

If you have suggestions for improving this article,