[Drupal 8] : How to add custom Block in module install
Do you want to add and enable some custom blocks while you install your module than below is the code you want to add into your install hook.
Let's read the code
We have implemented the hook_install which we used to add in modules .install file. Firstly we have created the block with Type and some info and added the body for block. Once we did that we created the blocks with settings for region in which we want place the block and then set the visibility for block.
Setting region for block:
Setting visibility for block:
After adding above code , go and enable your custom module. You can see the blocks in the region you want :)