Type Alias: BlockRegistry
BlockRegistry =
Record<string, () =>Promise<BlockComponent<never>>>
Defined in: registry.types.ts:71
A registry as the renderer holds it: block name → a function that imports that block's
component. It is the widened form of what defineRegistry returns, keyed by string because a
renderer indexes it by whatever names an artifact carries — which no literal type covers.
Annotate a variable with it to hand a registry around; build one with defineRegistry, which
keeps the literal's own keys where it is written and only widens to this at the render seam.
The stored component's props are never, which is why a value pulled straight out of a
registry cannot be invoked: nothing satisfies never. loadBlocks is where that is undone, so
load through it rather than calling an importer by hand.
Example
import type { BlockRegistry } from "@nubbin/react";
const registry: BlockRegistry = {
Hero: async () => (await import("./blocks/Hero")).Hero,
};
registry["Hero"]; // `(() => Promise<BlockComponent<never>>) | undefined`