UI extensions - Command line tools
We recommend creating apps instead of UI extensions. Read the app FAQ to learn why.
Extensions are built and managed within a Contentful space through the Content Management APIs
extension endpoint. To make it more convenient, the Create Contentful Extension CLI supports managing the extensions.
This article explains how to create and deploy a UI Extension from scratch using these Command line tools.
We recorded an eight minute video which gives an overview of the
Create a new UI Extension
To get started, generate your first extension using
npx @contentful/create-contentful-extension my-first-extension
It will ask you what type of extension you want to create:
- Field extension
- Sidebar extension
- Entry extension
- Page extension
Then it creates a directory called
my-first-extension inside the current folder.
my-first-extension ├── node_modules ├── .babelrc ├── .gitignore ├── .contentfulrc.json ├── package.json ├── extension.json └── src ├── index.html ├── index.js └── index.css
Once the installation is done, you can open your project folder and install all development dependencies:
cd my-first-extension && npm install
To start development run the following commands in the newly created
npm run login && npm run configure
It starts a new session with our CLI (Command Line Interface). As the Command line tool uses our Content Management API, you need to have a CMA access token to use all the commands.
Once you're successfully logged in, it asks what space and environment you want to use. Your answers (CMA token, space and environment ids) be will be saved to a local
When configuration part is finished you can actually start the development by typing the following command:
npm run start
It starts the development server and deploys the extension in development mode to the selected space. The extension will automatically reload if you make changes to the code.
Note: As Contentful runs in an HTTPS environment, temporarily disable the security checks in the browser. For example, "Load unsafe scripts" in Chrome.
Uploading a UI Extension to Contentful
When development is done, you need to install your extention to a space in production mode. To do so run the following command in your extension folder:
npm run deploy
It correctly bundles all extension dependencies in production mode and optimizes the build for the best performance, then it uploads build version of extension to a selected space.
Configuring a field to use an extension
Refer the section Assigning UI Extensions to a Field to assign the extension to the particular field where it needs to be used.
Managing UI Extensions via
Refer to our
Contentful uses optimistic locking to avoid accidental non-idempotent operations such as
While using the
delete subcommands, it is mandatory to specify the version of the extension using the
--version option. Alternatively, the
--force option can be used that instructs the CLI to use the latest version of the extension.
To manage an extension programmatically, refer the Content Management SDKs.
Not what you’re looking for? Try our FAQ.