Skip to main content
@wordpress/create-block is the official tool for scaffolding WordPress plugins that register blocks. It generates PHP, JS, and CSS code with a modern build setup requiring zero configuration.

Quick Start

1

Generate a new block plugin

This creates a new plugin folder named todo-list.
2

Navigate to the plugin directory

3

Start development

The build will automatically rebuild when you make changes.
4

Install the plugin

Copy the generated folder to your WordPress wp-content/plugins/ directory and activate it from the WordPress admin.
Requires Node.js >= 20.10.0 and npm >= 10.2.3

Usage

Basic Command

The slug defines:
  • Block slug (for identification)
  • Output folder name
  • WordPress plugin name

Interactive Mode

When you run the command without a slug, it prompts you for input:
Terminal

Options

—template

Specify an external npm package or local directory as a template.

—variant

Generate a dynamic block variant:
This creates a dynamic block that renders on the server.

—namespace

Specify a custom namespace for your block:
This creates my-namespace/my-block instead of create-block/my-block. Update the namespace in:
  • block.json - the name property

—no-plugin

Scaffold only block files without the plugin wrapper:
This runs in “No plugin mode” and scaffolds block files into the current directory.

—target-dir

Specify the output directory:

—title

Set the display title for the block and plugin:

—short-description

Set the short description:

—category

Set the block category:
Available categories:
  • text
  • media
  • design
  • widgets
  • theme
  • embed

—wp-scripts

Enable or disable integration with @wordpress/scripts:

—wp-env

Add @wordpress/env configuration to the generated plugin:
This allows you to easily set up a local WordPress environment for testing:
1

Generate block with wp-env

2

Start local environment

3

Access WordPress

Open http://localhost:8888
  • Username: admin
  • Password: password

—textdomain

Set a custom text domain for internationalization:
If not specified, the block’s slug is used as the default text domain.

—version

Display version information:

—help

Display usage information:

Complete Options Reference

Generated Project Structure

When you run create-block, it generates this structure:

Available Scripts in Generated Project

The generated plugin includes these npm scripts:
Starts the build for development with watch mode.
Automatically rebuilds when you make changes to the code.
Builds the code for production.
Generates optimized assets in the build folder.
Formats files using Prettier.
Lints CSS files using Stylelint.
Lints JavaScript files using ESLint.
Updates WordPress packages to the latest versions.
Creates a ZIP file of the plugin.
Useful for distributing your plugin.
You don’t need to configure webpack, Babel, or ESLint yourself. They’re preconfigured and hidden so you can focus on coding.

Examples

Create a Block with Custom Namespace

This creates:
  • Block name: acme/testimonial
  • Plugin folder: testimonial

Create a Dynamic Block

Generates a dynamic block that renders on the server, useful for displaying database-driven content.

Create Multiple Blocks (No Plugin Mode)

Add a new block to an existing plugin:

Create Block with Local Development Environment

Access your block at http://localhost:8888

Create Block from Custom Template

Block Development Workflow

1

Generate the block

2

Start development server

Watches for file changes and rebuilds automatically.
3

Edit block code

Modify files in the src directory:
  • block.json - block metadata
  • edit.js - editor interface
  • save.js - front-end output
  • style.scss - front-end and editor styles
  • editor.scss - editor-only styles
4

Test in WordPress

  1. Copy the plugin folder to wp-content/plugins/
  2. Activate the plugin in WordPress admin
  3. Add the block to a post or page
5

Build for production

Creates optimized production assets.
6

Create distribution package

Generates a ZIP file ready for distribution.

Understanding block.json

The block.json file contains your block’s metadata:
src/block.json
Key fields:
  • name - unique block identifier (namespace/slug)
  • title - display name in the editor
  • category - where the block appears in the inserter
  • icon - Dashicon or custom SVG
  • editorScript - JavaScript for the editor
  • editorStyle - CSS for the editor only
  • style - CSS for both editor and front-end

Block Templates

Create Block supports custom templates for different use cases.

Built-in Templates

External Templates

You can use external npm packages as templates:
Or local templates:

Tips and Best Practices

Choose descriptive, semantic names:Good:
  • testimonial
  • pricing-table
  • feature-grid
Avoid:
  • block1
  • custom-block
  • my-block
Use your company or project name as the namespace:
All your blocks should use the same namespace (e.g., acme/testimonial, acme/pricing-table).
Blocks should be part of plugins, not themes. This ensures blocks continue working when users change themes.
Add --wp-env flag to quickly test your block:
Regularly update WordPress packages:

Troubleshooting

Error: create-block requires Node.js 20.10.0 or higherSolution: Update Node.js:
Checklist:
  1. Is the plugin activated?
  2. Did you run npm run build or npm start?
  3. Are there errors in the browser console?
  4. Is the block name in block.json unique?
Solution: Clean install dependencies:
Check:
  1. Are style imports in index.js?
  2. Did the build complete successfully?
  3. Are the CSS files in the build folder?
  4. Is the plugin enqueuing assets correctly?

Next Steps

After creating your block:

Block Editor Handbook

Learn about block development concepts and APIs

Block API Reference

Explore block registration and block.json options

@wordpress/scripts

Learn about available build commands and options

@wordpress/env

Set up a local WordPress environment for testing

Package Information

  • Version: 4.83.0
  • Node.js: >= 20.10.0
  • npm: >= 10.2.3
  • License: GPL-2.0-or-later
  • Binary: wp-create-block