@nullplatform/ui-plugin-sdk
v0.20.0
Published
SDK for nullplatform UI plugins: catalog components, bridge client and defineUI
Keywords
Readme
nullplatform UI plugin SDK
Build widgets and pages for nullplatform's UI plugin host.
npm install @nullplatform/ui-plugin-sdk react react-domimport { defineUI, Card, Text } from '@nullplatform/ui-plugin-sdk';
function Summary() {
return <Card title="My plugin"><Text>Hello</Text></Card>;
}
defineUI({ widgets: { summary: Summary } });Build one self-contained classic IIFE (including React and the SDK). The host runs it in an isolated worker and renders its remote components using the host's design system. Declare registered mountpoints, widgets and bridge permissions in your plugin manifest.
The same package provides DOM-free validation for Node tooling and APIs:
import { validateManifest } from '@nullplatform/ui-plugin-sdk/contract';
// CommonJS: require('@nullplatform/ui-plugin-sdk/contract')nullplatform.api accesses allowed nullplatform API paths through the host.
nullplatform.http accesses explicitly declared external hosts using short-lived
plugin tokens. nullplatform.assets.url(path) resolves a file from the installed
bundle; Image displays images/SVG from platform storage.
The SDK carries no API keys. Publish your plugin bundle through the UI API, pin it
as a ui_bundle component of a central nullplatform Package, and install the exact
package revision on the desired NRN. Installing this npm SDK does not publish or
install a plugin in nullplatform.
Local development
npm install --save-dev vite @vitejs/plugin-react
npx ui-plugin-sdk dev --httpsui-plugin-sdk dev rebuilds the plugin with your project's Vite on every change and
serves manifest.json, dist/plugin.js and fixtures.json on localhost:4300
(--port to change it). The nullplatform dashboard only loads https://localhost,
so serve with --https and a locally trusted certificate, by default
.certs/localhost.pem and .certs/localhost-key.pem:
mkcert -install
mkcert -cert-file .certs/localhost.pem -key-file .certs/localhost-key.pem localhost 127.0.0.1fixtures.json holds test answers for the plugin's API calls, keyed like the
manifest's permissions.api. A preview answers from it instead of the API, and a
call with no fixture fails as a 404:
{
"GET /application/{id}": { "id": 42, "name": "checkout-api" },
"GET /scope": { "results": [{ "id": 1, "name": "production" }] }
}The query string is not part of the key, and a key with more literal segments wins
(/application/me over /application/{id}).
