Author a scoped command plugin
A plugin is a manifest plus JavaScript module exporting named commands. Server execution runs in a Bun worker hosting QuickJS-WASM without native filesystem, database, environment or independent network access. All exposed work crosses the website-scoped bridge and its owner grants.
Before you start
Section titled “Before you start”- Develop on synthetic website content. Use the current manifest and input schemas instead of assuming full JSON Schema or npm runtime support.
-
Create
manifest.json:{"manifest":1,"id":"hello-docs","name":"Hello docs","version":"1.0.0","permissions":[],"commands":[{"id":"hello","label":"Say hello","input":{"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}}]}Command inputs support a flat object of string, number and boolean properties, optional string enums and required keys; maximum 20 properties and 20 commands.
-
Create
plugin.js:export default {commands: {hello: (input) => `Hello, ${input.name}`}}Install both files through Plugins and run hello with a synthetic name. This example requests no content, network or editor-code permission.
-
For content commands, await methods such as
strukt.content.pages(),collections(),entries(collectionId)or draft-writing methods. Declare content.read/content.write as needed. Writes create/save drafts; the bridge does not grant an implicit publish operation. Handle conflict/revoked/forbidden errors without bypassing the bridge. -
For network work, declare the specific allowed HTTPS hosts and use
strukt.fetch(). Its reply exposes response text through the bridge contract; do not assume a native Response object. Await console logging when its completion matters. Test denied hosts and revoked grants. -
Inspect run status and bounded failures including timeout/memory. Do not perform privileged work at module load; keep actions inside commands. Treat editor.code as a separate opt-in capability and avoid requesting it for a server-only task.
Check the result
Section titled “Check the result”- The minimal command returns the expected greeting and denied bridge operations fail without affecting another website.
Troubleshooting
Section titled “Troubleshooting”If the module fails to load, inspect syntax/default export and command IDs first. Missing grants are not solved by importing Bun or Node modules into the isolated runtime.
Related guides
Section titled “Related guides”- Install plugins and review permissions
- Internal API boundaries and diagnostics
- Understand architecture and extension contracts
Applies to Strukt c02552848c92 · 2026-10-31