The documentation says register_block_type() "registers a block type"..
register_block_type can also be used to load in JS blocks. You can register a block and declare the CSS/JS/etc files to load.
For example, see this code snippet posted in the comments of the official documentation page:
register_block_type( 'mcqac/related-quiz', array(
'editor_script' => 'mcqac-related-quiz-block-script',
'editor_style' => 'mcqac-related-quiz-block-editor-style',
'style' => 'mcqac-related-quiz-block-frontend-style',
Alternatively you could provide a render callback and render the block server side in PHP.
It uses the WP_Block_Type_Registry class, but I don't really understand what the class does.
Not quite, it uses
WP_Block_Type. It has to store that data somewhere, rather than storing it as an array with no definition, it stores it as a structured object.
This object provides some helper methods for dealing with blocks of that type, as well as helper methods for rendering blocks of that type if you pass in the given attributes. Although this only works for dynamic PHP rendered blocks.
WP_Block_Type_Registry is just the class type of the object that holds all of the block types. A similar structure exists in JS.
Similar class types exist for every major object type in WordPress, e.g.
WP_Post_Type. As with most classes in WordPress, it isn't about what they do, but what they are/contain. Most WP core objects you will deal with are data containers of some form with a handful of helper methods, or, they're query objects such as
Anyone could help me understand what register_block_type() does exactly and what is the difference with wp.blocks.registerBlockType()?
One is PHP the other is JS, they're intended to do the same thing, register a block. It's just that sometimes you need to render things server side, so a way to register things in PHP is desirable.