Skip to main content
Block registration makes your block available in the WordPress Block Editor. You register blocks using the 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 object
object
required
Block configuration object containing edit, save, and other properties

Returns

object
The registered block type object, or undefined if registration fails

Registration Methods

Method 1: JavaScript-Only Registration

The recommended method uses a block.json metadata file: block.json
index.js
edit.js
save.js

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, embed
string | 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.json
index.js

Block Collections

Group related blocks together in the inserter:

Unregistering Blocks

Remove previously registered blocks:
Unregistering core blocks may break existing content. Only unregister blocks if you’re certain they’re not being used.

Server-Side Registration

Register blocks in PHP for better performance:
This automatically reads block.json and registers the block on both server and client.

Validation and Error Handling

The registerBlockType 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