defineBlokkli() is a compiler macro and composable auto-imported by the blökkli Nuxt module. Call it inside <script lang="ts" setup> in every block component to register the component as a blökkli block and declare its options. At build time, blökkli reads your defineBlokkli() calls to generate typed option resolvers, chunk manifests, and editor metadata.
Signature
Parameters
The unique bundle identifier for this block type. Must exactly match the bundle string in your block data (e.g. the paragraph machine name in Drupal, or the
type field from your API).Examples: 'text', 'hero', 'image-gallery'Local option definitions for this block. Each key is an option name; each value is an option definition object. Options are rendered as controls in the blökkli editor sidebar. The resolved values are returned as a reactive
ComputedRef by defineBlokkli().See Block Options for all available option types (radios, checkbox, range, select, text, and more) and their full configuration properties.An array of global option keys to include on this block. Global options are defined once in
nuxt.config.ts under blokkli.globalOptions and reused across all blocks that opt in — useful for shared concerns like color scheme or spacing scale.Override editor behaviors for this specific block. All properties are optional.
Named async chunk for code splitting. Blocks that share the same
chunkName are bundled into a single lazy-loaded chunk. Group blocks that are typically used together (e.g. all form-related blocks) to reduce the number of network requests on first load.A constraint array that limits where this block is rendered. Each entry is an object specifying conditions such as entity type or bundle. Blocks are only rendered when their constraints match the current context; non-matching blocks are skipped during render.
Return Value
defineBlokkli() returns an object with a single property:
Reactive resolved option values. Updates automatically when the user changes options in the editor. Access individual values as
options.value.myOptionKey in <script setup>, or as options.myKey directly in templates — Vue unwraps ComputedRef automatically in template expressions.Full Example
The following component demonstrates acard block with three local options and one global option:
variant, a Checkbox for showImage, and a Range slider for gap in the options sidebar — with no additional configuration required.
