Can you render a custom block in a view without adding it to the admin blocks page? I made a custom block in my custom module.  I now want to show that block in the &quot;No results&quot; area of a view, but I can't get it to render (I don't see any error message, and I don't see any output).
Here is the block definition:
/**
 * Provides an 'New User' Block.
 *
 * @Block(
 *   id = &quot;newuser_block&quot;,
 *   admin_label = @Translation(&quot;New user block&quot;),
 *   category = @Translation(&quot;MYMODULE&quot;),
 * )
 *

In my view, in the &quot;No results&quot; section, I added Rendered entity - Block, and set the Block ID to newuser_block.
However, the block does not get rendered.
This is because I did not add the block on the block admin page at /admin/structure/block. When I add the block on the admin page and use the admin page block ID (not the block machine name), the block is rendered correctly.
However, I don't want to add the block to the admin page because I only need this block in a few places on my site, so I was using Layout Builder to inject the block where necessary.
So, is there a way to inject a block by machine name (instead of by the ID used on the block admin page) in Views?
The only purpose of a block plugin is to be placed as a block. It's not an entity. The placed block instance can become an entity of its own but also be part of a layout section.
Since the block is your own custom code you don't need any of the workarounds discussed and linked. It would make more sense to refactor the code and expose it as block plugin to be placed on the page and at the same time as area plugin to be placed in a View.
For sharing the custom code between both plugins you can use classic OOP, or the in Drupal very common traits and services. The service has the advantage that it is more flexible and you can not only share code but also data, for example to cache the result if it is expensive to calculate and used in multiple places.