defineBlokkli() inside its <script setup> block. blökkli uses the bundle identifier you provide to match incoming block data to the correct component — think of it as the contract between your backend data model and your frontend rendering logic.
File Naming Convention
Block components live in thecomponents/Blokkli/ directory and are named after their bundle using PascalCase:
| File path | Bundle identifier |
|---|---|
components/Blokkli/Text.vue | text |
components/Blokkli/HeroTeaser.vue | hero_teaser |
components/Blokkli/CardGrid.vue | card_grid |
The PascalCase-to-snake_case conversion is automatic.
MyBlock.vue maps to the bundle my_block. Make sure your backend returns bundle strings that match this convention.Basic Example
The minimal block component defines a bundle and usesdefineProps to receive its data:
defineProps declaration should match the shape of the data your backend returns for that bundle.
With Options
Options let content editors customise a block’s appearance and behaviour directly from the editor panel. Define them indefineBlokkli() and destructure the reactive options object from the return value:
options is fully reactive — when a content editor changes a value in the editor panel, the component re-renders immediately without a page reload.
With Global Options
Global options are reusable option definitions you declare once innuxt.config.ts and then attach to any block. This is useful for site-wide concerns like spacing scales or colour schemes:
options object merges both global and local values, so you access them all through the same reactive reference.
defineBlokkli() Parameters
Unique identifier for the block type. Must match the bundle string returned by your backend data source. blökkli uses this value to look up the correct component at render time.
Block-level options object. Each key is an option name and each value is an option definition describing the input type, label, and default value. Options appear in the editor’s options panel for this block. See Block Options for the full type reference.
Array of global option keys to include for this block. Global options are declared once in
nuxt.config.ts under blokkli.globalOptions and shared across many blocks. The values are merged into the returned options object alongside any local options.Editor behaviour overrides for this block. Use this to control how the block behaves inside the editor UI. For example, passing
{ disableEdit: true } prevents the edit form from opening when a content editor clicks on the block.Groups this block component into a named async chunk for code splitting. Blocks that share the same
chunkName are bundled together. Use this to optimise loading performance when you have many block types — group rarely-used blocks into a separate chunk so they don’t inflate your initial bundle.Constraint array controlling when this block component is rendered. Use it to restrict a block to specific entity types or bundles — for example, rendering a different variant of a block only within a particular page type.
Return Value
defineBlokkli() returns an object with a single property:
| Property | Type | Description |
|---|---|---|
options | Reactive<YourOptions> | A reactive object containing the current values of all defined options (both local and global). Values update live when the content editor makes changes in the editor panel. |
options is always reactive, even if you haven’t defined any options. In that case it resolves to an empty reactive object. You only need to destructure it when you actually use options in your template or script.
