The packages on npm
Four packages on npmjs.com give you what a plugin needs. All four are MIT licensed.
| Package | Holds | Used |
|---|---|---|
@relatude/create-plugin |
the starter: a working plugin with its build set up | once, by npm create @relatude/plugin <folder> (A first plugin) |
@relatude/plugin-kit |
relatudePlugin(), the Vite build of a plugin, and the relatude-plugin dev command |
in vite.config.mjs, and by npm run dev |
@relatude/sdk |
definePlugin, useCms, the types of the CMS services and extension points, and the db client (chapter 19) |
in every plugin |
@relatude/ui |
the interface's components and design tokens (The component library) | in a plugin's screens |
Each package's page on npmjs.com has a short example. Their type declarations carry doc comments, which your editor shows.
They give the types and the build. A plugin installs the packages, React and React's types as
dev dependencies. Your editor and tsc read their types, and the build resolves their imports.
relatudePlugin() then leaves react, react-dom, @relatude/sdk and @relatude/ui out of the
bundle, and in the CMS the plugin uses the interface's own copies. So they add nothing to the
plugin's size, and the plugin runs on the SDK of the interface that loads it.
One version for all four. The packages are released together, under one version number: the
version of the SDK they describe. Keep the three a plugin installs at one version, and upgrade them
together. The starter asks for its own version of each, and sets sdk in definePlugin to match
('^1.0').
Prereleases. Until 1.0 is released, the versions are prereleases such as 1.0.0-alpha.1,
published under the dist-tag alpha. Name the tag when you create a plugin and when you upgrade
one:
npm create @relatude/plugin@alpha my-plugin
npm install -D @relatude/sdk@alpha @relatude/ui@alpha @relatude/plugin-kit@alphanpm view @relatude/sdk dist-tags shows which version each tag points at.
What they need. @relatude/sdk and @relatude/ui need React 19, and @relatude/plugin-kit
needs Vite 5 or newer. The starter asks for React 19, Vite 6 and TypeScript 5.
In a project of your own. The starter is the easiest start. To build a plugin in an existing project instead, install the packages:
npm install -D @relatude/sdk @relatude/ui @relatude/plugin-kit vite typescript react @types/reactThen add vite.config.mjs as in A first plugin, a tsconfig.json as in
TypeScript, and these scripts to package.json:
"scripts": {
"dev": "relatude-plugin dev",
"build": "vite build",
"typecheck": "tsc --noEmit"
}The build starts from src/index.tsx; relatudePlugin({ entry: 'src/plugin.tsx' }) names another
file.
Outside the CMS interface, such as on a page of the site that reads content through the db
client, @relatude/sdk is an ordinary dependency, bundled like any other.