registerBlockType function from the @wordpress/blocks package.
registerBlockType Function
string | object
required
Either a block name string (
namespace/block-name) or a block.json metadata objectobject
required
Block configuration object containing edit, save, and other properties
Returns
object
The registered block type object, or
undefined if registration failsRegistration Methods
Method 1: JavaScript-Only Registration
Method 2: Using block.json (Recommended)
The recommended method uses ablock.json metadata file:
block.json
Block Configuration Properties
Core Properties
string
required
Display title shown in the inserter. Should be translated with
__() function.string
required
Block category. Core categories:
text, media, design, widgets, theme, embedstring | element | object
Icon for the block. Can be a Dashicon slug, SVG element, or icon descriptor object.
string
Short description shown in the block inspector
array
Search terms to help users find the block
Attributes
object
Block data structure definition. See Block Attributes for details.
Block Hierarchy
array
Restrict block to only be available when nested within specified parent blocks
array
Block available anywhere within specified ancestor blocks (not just direct children)
array
Restrict which block types can be nested as direct children
Styles and Variations
array
Alternative visual styles for the block
array
Block variations with different initial configurations. See Block Variations API
Block Example
object
Provides structured data for block preview in inspector and styles panel
Real-World Example: Paragraph Block
Here’s how the core Paragraph block is registered: block.jsonBlock Collections
Group related blocks together in the inserter:Unregistering Blocks
Remove previously registered blocks:Server-Side Registration
Register blocks in PHP for better performance:block.json and registers the block on both server and client.
Validation and Error Handling
TheregisterBlockType function validates your block configuration:
TypeScript Type Definition
Next Steps
Define Block Attributes
Learn how to structure your block’s data
Use Block Supports
Enable editor features automatically