If you want to get list of all blocks then you can use getBlockTypes
from block store. We can use @wordpress/blocks
package to retrieve block store. useSelect
hook from @wordpress/data
package will be used to access getBlockTypes
function from block store. It can only be used in a component. Here is an example
/**
* WordPress dependencies.
*/
import { store as blocksStore } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
const TestComponent = () => {
const blockTypes = useSelect(
( select ) => select( blocksStore ).getBlockTypes(),
[]
);
return (
<ul>
{ blockTypes.map( ( block ) => (
<li key={ block.name }>{ block.title }</li>
) ) }
</ul>
);
};