@wordpress/create-block tool. You’ll have a working block in just a few minutes.
Prerequisites
Before you begin, ensure you have:- Node.js version 20.10.0 or above
- npm version 10.2.3 or above
- A WordPress installation (local or remote)
Create Your First Block
Scaffold the Block
Open your terminal and run the This creates a new WordPress plugin with a custom block named
create-block command with your desired block name:my-first-block. The command scaffolds all necessary files including:- PHP plugin file
- JavaScript source files
- Block configuration (
block.json) - Build configuration
- CSS styles
Start the Development Build
Start the development build process with watch mode:This command runs a continuous build that automatically rebuilds your block whenever you make changes to the source files.
The development build includes additional warnings and helpful error messages. For production, use
npm run build instead.Install the Plugin in WordPress
Copy or symlink the entire plugin folder to your WordPress installation:Then activate the plugin in your WordPress admin under Plugins.
Understanding the Generated Files
Thecreate-block tool generates a complete plugin structure:
Customizing Your Block
Let’s make a simple change to see the workflow in action:Watch the Auto-Rebuild
If
npm start is running, your changes are automatically compiled. Check your terminal for confirmation.Using a Custom Namespace
By default, blocks are created with thecreate-block namespace. You should use your own unique namespace:
my-company/my-block instead of create-block/my-block.
Available npm Scripts
Your scaffolded plugin includes several useful commands:Next Steps
Now that you have a working block, explore more advanced topics:Create Your First Block
Deep dive tutorial on block development
Block Editor Handbook
Complete documentation and API reference
Block Supports API
Add common features to your blocks
Development Environment
Set up a complete local development environment
Troubleshooting
npm start fails with Python error
npm start fails with Python error
The install scripts require Python to be installed. Download and install Python from python.org and ensure it’s in your system PATH.
Block doesn't appear in the inserter
Block doesn't appear in the inserter
- Ensure the plugin is activated in WordPress
- Check that
npm startornpm run buildcompleted successfully - Clear your browser cache and reload the editor
Changes not reflecting in the editor
Changes not reflecting in the editor
- Verify
npm startis running and watching for changes - Hard refresh your browser (Ctrl+Shift+R or Cmd+Shift+R)
- Check the browser console for JavaScript errors