To upgrade to the latest version of contentful-management, use your package manager and then make any necessary changes outlined in the migration guides below.
npm:
npm install contentful-management@latestyarn:
yarn upgrade contentful-management@latestpnpm:
pnpm update contentful-management@latestVersion 12 modernizes the build pipeline of contentful-management to bring full ESM support, with CommonJS variants still available for legacy environments. This version is a significant step forward in modernizing our build and improving performance while maintaining wide compatibility across various environments.
Estimated migration time: Most projects can complete this migration in under 30 minutes.
If you are affected by any of the items below, follow the upgrade guides in the sections
- Projects using Node.js versions older than v20 (Node.js v20+ support)
- Projects targeting browsers that do not support ES2021 (ESM target updated to 2021)
- Code directly importing old bundle paths (New bundles available)
- Code relying on the bundle including all dependencies (Package bundles no longer include projects dependencies)
- Code using the browser bundle with direct method access (Changes to browser bundle)
- Code using deep imports from internal modules (Use of new
exportsfield in package.json) - TypeScript projects importing from
contentful-management/typeswith older module resolution (Importing Types from 'contentful-management/types') - Code using the
Streamtype (Breaking Changes) - Code using the
entry.patchmethod (Version param is now required for entry patch method) - Code relying on the default nested (legacy) client (Default client changed from nested to plain)
- Code using the
DefaultParamstype (DefaultParams renamed to PlainClientDefaultParams) - Code using the
ClientParamstype (ClientParams type removed) - Code using
ContentfulEntryApior other*Apitypes (API type naming standardized) - Code using the
alphaFeaturesoption increateClient(alphaFeatures option removed)
We dropped support for versions of Node that were no longer LTS and now support Node v20+.
Compatibility:
- ✅ Node.js v20+
- ❌ Node.js v18 and below
You will need to update the version of Node in your projects if it is less than v20.
The library now targets ECMAScript 2021, and Babel transpilation for older JavaScript versions has been removed. This means modern JavaScript features like optional chaining (?.), nullish coalescing (??), and Promise.any() are used directly without transpilation.
Affected environments:
- Internet Explorer (all versions)
- Chrome < 85
- Firefox < 79
- Safari < 14
- Edge < 85
- Node.js < 14.17
Browser and Node environments that do not support ES2021 might need an additional transpilation step with Babel to continue to work.
The following old bundles have been removed:
- ./dist/contentful-management.node.js
- ./dist/es-modules/contentful-management.js
- ./dist/contentful-management.browser.js
And have been replaced with an ESM build for use in modern environments, a CommonJS build for legacy environments, and a browser bundle suitable for including directly with a script tag:
- ./dist/esm/index.mjs
- ./dist/cjs/index.cjs
- ./dist/browser/index.min.js
If you were accessing any of the previous bundles directly, you will need to update to pull from one of the new bundles.
import example:
// Before
import contentful from './node_modules/contentful-management/dist/contentful-management.node.js'
// After (ESM)
import contentful from 'contentful-management'
// After (CommonJS) - still works
const contentful = require('contentful-management')The old 'contentful-management.node.js' and 'contentful-management.browser.js' bundles included all the project's dependencies in the bundle itself. The dependencies are not included in the new ESM or CJS bundles, but are still included in the browser bundle.
Thus, we have noticed that some project build systems might fail upon updating to v12 when contentful-management tries to import one of its dependencies and the project is not set up to transpile code in node_modules. A particular instance is when the main project is CommonJS and it tries to import 'contentful-sdk-core', which is an ESM-only library. Build systems might need to be updated to transpile 'contentful-sdk-core' into CommonJS so it can be included.
To mitigate this issue, we will look into shipping CommonJS (along with ESM) versions of 'contentful-sdk-core'.
Browser bundle methods must now be accessed from the contentfulManagement object which is added to window on load (e.g., window.contentfulManagement.createClient()). If you were using methods directly, update your code to destructure them from the contentfulManagement object (e.g., const { createClient } = contentfulManagement).
JSDelivr usage:
<!-- Before -->
<script src="https://cdn.jsdelivr.net/npm/contentful-management@11/dist/contentful-management.browser.min.js"></script>
<!-- After -->
<script src="https://cdn.jsdelivr.net/npm/contentful-management@12"></script>See the Browser Bundle In Script Tag section in the main README for more info.
The exports field in package.json now restricts access to internal module files. If you were previously using deep imports (e.g., import { SomeValue } from 'contentful-management/dist/subfolder/SomeValue'), they will no longer work. This likely means you were importing something not intended to be part of the public API. Try importing directly from contentful-management instead. If the export you need is still unavailable, please file an issue so we can evaluate whether it should be exposed publicly.
All types are exported from both contentful-management and contentful-management/types for backwards compatibility. However, contentful-management/types now use the new exports field described above. Older module resolution strategies might not support importing types this way. You'll need to either update moduleResolution in your tsconfig.json to a modern value (e.g., node16 or higher), or import types directly from contentful-management instead.
Migration options:
Option 1 - Update tsconfig.json:
{
"compilerOptions": {
"moduleResolution": "node16" // or "bundler" or "nodenext"
}
}Option 2 - Import from main package:
// Instead of
import type { Space } from 'contentful-management/types'
// Use
import type { Space } from 'contentful-management'The version parameter is now required when calling client.entry.patch(). Previously, the TypeScript types incorrectly marked version as optional, even though the method implementation always expected it to be provided.
What changed:
- The
versionparameter inentry.patch()is now required in the TypeScript types - Previously, some users worked around the missing type by passing
versionvia theX-Contentful-Versionheader, which will no longer be necessary
Migration:
If you were previously passing version in the headers or not passing it at all, you'll need to update your code to include version in the params object:
// Before (if you were using headers workaround)
await client.entry.patch({ spaceId: 'xxx', environmentId: 'xxx', entryId: 'yyy' }, patches, {
'X-Contentful-Version': '123',
})
// After
await client.entry.patch(
{ spaceId: 'xxx', environmentId: 'xxx', entryId: 'yyy', version: 123 },
patches,
)Why this change:
The version parameter was always expected by the implementation (it gets transformed into the X-Contentful-Version header internally), but the TypeScript types were incorrect. This fix aligns the types with the actual API behavior and ensures proper type safety.
The update method for concept and conceptScheme now performs a PUT request instead of a PATCH request.
- If you were using
update()withOpPatch[], usepatch()instead - If you were using
updatePut(), useupdate()instead. The newupdateis identical to the oldupdatePut.
The createClient function now defaults to the plain client instead of the nested (legacy) client.
What changed:
- Previously, calling
createClient({ accessToken: 'token' })returned the nested client - Now, the same call returns the plain client
- To continue using the legacy nested client, you must explicitly pass
{ type: 'legacy' }
Migration:
If you need to continue using the legacy nested client, update your code to explicitly request it:
// Before - implicitly used nested client
const client = createClient({ accessToken: 'token' })
// After - explicitly request legacy nested client
const client = createClient({ accessToken: 'token' }, { type: 'legacy' })Recommended: We strongly recommend migrating to the plain client API, as the legacy nested client is deprecated and will be removed in the next major version. See the README for migration guidance.
The DefaultParams type has been renamed to PlainClientDefaultParams to avoid confusion with legacy client params.
Migration:
// Before
import type { DefaultParams } from 'contentful-management'
// After
import type { PlainClientDefaultParams } from 'contentful-management'The ClientParams type has been removed as it was outdated and confusing. Use ClientOptions instead for typing client creation options.
Migration:
// Before
import type { ClientParams } from 'contentful-management'
// After
import type { ClientOptions } from 'contentful-management'API type names have been standardized to use uppercase API suffix instead of Api for consistency with existing conventions.
Renamed types:
ContentfulEntryApi→ContentfulEntryAPIContentfulEnvironmentTemplateApi→ContentfulEnvironmentTemplateAPIContentfulUIConfigApi→ContentfulUIConfigAPI
Additionally, create-user-ui-config-api.ts previously exported ContentfulUIConfigApi (same name as create-ui-config-api.ts), which has been renamed to ContentfulUserUIConfigAPI to fix this duplicate name bug.
Migration:
// Before
import type { ContentfulEntryApi } from 'contentful-management'
// After
import type { ContentfulEntryAPI } from 'contentful-management'The alphaFeatures option has been removed from createClient as it was deprecated, unsupported, and unused.
Migration:
If you were passing alphaFeatures to createClient, simply remove it:
// Before
const client = createClient({
accessToken: 'token',
alphaFeatures: { includeContentSourceMaps: true },
})
// After
const client = createClient({
accessToken: 'token',
})Cause: Youre using deep imports to internal modules.
Solution: Import from the main contentful-management package instead. If you need access to a specific export that's not available, please file an issue.
Cause: Your TypeScript configuration uses an older module resolution strategy.
Solution: Update your tsconfig.json:
{
"compilerOptions": {
"moduleResolution": "node16"
}
}Or import types directly from contentful-management instead of contentful-management/types.
Cause: Your environment doesn't support ES2021.
Solution:
- For Node.js: Upgrade to Node.js v20 or higher
- For browsers: Ensure you're targeting modern browsers that support ES2021 (Chrome 85+, Firefox 79+, Safari 14+, Edge 85+)
- Consider using a transpilation tool like Babel if you must support older environments
Possible causes:
- Outdated module resolution in
tsconfig.json - IDE needs to be restarted after upgrade
- Type cache needs to be cleared
Solutions:
- Update
moduleResolutiontonode16or higher - Restart your IDE/TypeScript server
- Delete
node_modulesand reinstall:rm -rf node_modules && npm install
- Review the CHANGELOG for all changes
- Check the README for updated usage examples
- File an issue if you encounter problems