Each minor release of the Spartacus library contains new features, often improvements to existing components. These features are usually expected by users, but in some cases these updates can be seen as disruptive changes, especially if you build your own customizations on top of a particular behavior or DOM structure.

Feature level

To maintain strict backward compatibility, Spartacus includes configurable levels of functionality that help maintain predictable behavior while improving existing components.

By default, the feature level is set to the latest major release (for example, 1.0). To take advantage of the new behaviors and improvements introduced in minor releases (such as 1.3), you can configure the level of functionality, as shown in the following example:

{
  features: {
    level: '1.3'}}Copy the code

Each successive feature level contains all the features of the previous feature level.

If you want your feature level to always be set to the latest version, you can use the latest flag (‘*’), as shown below:

features: {
  level: The '*'
}
Copy the code

You can also add an exclamation mark (!) before the version number. To disable functionality for a specific functionality level. Here’s an example:

<newComponent *cxFeatureLevel="'! 1.1 '"></newComponent>
Copy the code

Feature Flags

Some important functions can be switched selectively using specific function flags.

Here’s an example:

{
  features: {
    someFeature: false}}Copy the code

Feature flags can be linked to feature levels, and if defined feature levels are available, features are enabled by default.

You can configure both the function level and the function flag, as shown in the following example:

{
  features: {
    level: '1.1'.feature1: false.feature2: true}}Copy the code

In this example, the function level is set to 1.1. Set Feature1 to false. If Feature1 is normally part of the 1.1 feature set, you can optionally disable this feature while keeping the rest of the 1.1 features.

If Feature2 is part of version 1.5, you can enable it by setting it to true, otherwise you can only enable features from version 1.1.

If you selectively enable functionality, it is recommended that you pay special attention to testing your application. Although feature flags are used for many different Spartacus features, there is no guarantee that all features will apply to all possible combinations of feature flags and feature levels.