This guide will help you build a basic block that demonstrates the Interactivity API in WordPress.
Prerequisites
You will need a WordPress development environment to install and activate the plugin you build in this guide. Refer to the Development Environment setup guide for details on how to get started.
Scaffold an interactive block
Start by ensuring you have Node.js and npm installed on your computer. Review the Node.js development environment guide if not.
Next, use the @wordpress/create-block package and the @wordpress/create-block-interactive-template template to scaffold the complete “My First Interactive Block” plugin.
Choose the folder where you want to create the plugin, and then execute the following command in the terminal from within that folder:
npx @wordpress/create-block@latest my-first-interactive-block --template @wordpress/create-block-interactive-template
The slug provided (my-first-interactive-block) defines the folder name for the scaffolded plugin and the internal block name.
Basic usage
Once the plugin is scaffolded, navigate into the newly created plugin folder and start the development process with the following command:
cd my-first-interactive-block && npm start
When