跳到主要内容

Features configuration

The config/features.js|ts file is used to enable feature flags. Currently this file only includes a future object used to enable experimental features through future flags.

Some incoming Strapi features are not yet ready to be shipped to all users, but Strapi still offers community users the opportunity to provide early feedback on these new features or changes. With these experimental features, developers have the flexibility to choose and integrate new features and changes into their Strapi applications as they become available in the current major version as well as assist us in shaping these new features.

Such experimental features are indicated by a Feature FlagThis feature requires a feature flag to be enabled. badge throughout the documentation and enabling these features requires enabling the corresponding future flags. Future flags differ from features that are in alpha in that future flags are disabled by default.

Warning

Enable future flags at your own risk. Experimental features may be subject to change or removal, may contain breaking changes, may be unstable or not fully ready for use, and some parts may still be under development or using mock data.

Enabling a future flag

To enable a future flag:

  1. (optional) If the server is running, stop it with Ctrl-C.
  2. Open the config/features.js|ts file or create it if the file does not exist yet. The file will export a future object with all the future flags to enable.
  3. To enable a future flag, add its property name (see full list) to the future object and ensure the property's value is set to true. The following example shows how to enable the preview future flag:
/config/features.ts
module.export = ({ env }) => ({
future: {
// You could also simply write: preview: true
preview: env.bool('STRAPI_FUTURE_PREVIEW', false),
},
})

This example assumes that you have an .env environment file at the root of your application and that the file includes the following line:

.env
STRAPI_FUTURE_PREVIEW=true

If your environment file does not include this value, the preview future flag property value will default to false and the experimental feature will not be enabled.

  1. Rebuild the admin panel and restart the server:
  yarn develop

Future flags API

Developers can use the following APIs to interact with future flags:

  • Features configuration is part of the config object and can be read with strapi.config.get('features') or with strapi.features.config.

  • strapi.features.future returns the isEnabled() that can be used to determine if a future flag is enabled, using the following method: strapi.features.future.isEnabled('featureName').

Available future flags

There are currently no available future flags. This section will be updated once new experimental features are available for testing.