Skip to content

Build your first plugin

In this guide you build Houseplants, a small plugin that adds a new kind of item, a Plant, with a home screen that lists your plants, a form to add one and a page for each plant. It takes about fifteen minutes, and at the end you install it on your own Ryot server.

You need to be comfortable with TypeScript and React. Everything else is explained as you go, and How plugins work covers the ideas in more depth.

You need:

  • Git and Bun.
  • A Ryot server with Ryot Pro, because installing private plugins needs Pro.
  1. Clone the repository:

    Terminal window
    git clone https://github.com/IgnisDa/ryot.git
    cd ryot
  2. Check out the same version of Ryot that your server runs. A plugin built from a different version can be refused with “This archive was not built for this version of Ryot.”

  3. Install the dependencies:

    Terminal window
    bun install

Every plugin is a package in the plugins/ folder. When you are done, yours looks like this:

  • Directoryplugins/houseplants
    • package.json
    • Directorymanifest/
      • plugin.ts describes the plugin to Ryot
    • Directoryshared/
      • plugin-identity.ts
      • Directorymessages/
        • en.json every piece of text the plugin shows
    • Directoryclient/ the screens
      • home.tsx
      • new-plant.tsx
      • plant-page.tsx
      • plants-recipe.ts

Create plugins/houseplants/package.json. Its exports entry tells the build where the manifest is, and the build script runs the ryot command-line tool:

plugins/houseplants/package.json
{
"name": "houseplants-plugin",
"private": true,
"type": "module",
"exports": { ".": { "default": "./manifest/plugin.ts" } },
"scripts": { "build": "ryot plugin build" },
"dependencies": {
"@ryot-app/contract": "workspace:*",
"@ryot-app/plugin-client-sdk": "workspace:*",
"@ryot-app/plugin-kit": "workspace:*",
"@ryot-app/plugin-ui-sdk": "workspace:*"
},
"devDependencies": { "@ryot-app/cli": "workspace:*" }
}

Every plugin has a permanent package ID in the form publisher/name. Pick your own publisher name: lowercase letters, numbers and dashes. ryot is reserved for the built-in plugins.

plugins/houseplants/shared/plugin-identity.ts
import { PluginPackageId } from "@ryot-app/plugin-kit/schema";
export const PLUGIN_PACKAGE_ID = PluginPackageId.make("yourname/houseplants");

Plugins never hard-code text that people see. Every label, title and message lives in a catalog, so it can be translated later. English is required:

plugins/houseplants/shared/messages/en.json
{
"plugin.name": "Houseplants",
"plugin.description": "Keep track of your houseplants.",
"entity-schema.plant.name": "Plant",
"property.species": "Species",
"property.watering-interval": "Water every (days)",
"home.title": "My plants",
"home.add": "Add plant",
"home.empty": "No plants yet.",
"home.plant": {
"message": "{name} ({species})",
"description": "One plant in the list. {name} is the plant's name and {species} its species."
}
}

The build turns this file into a typed catalogMessage function in shared/messages.generated.ts, so a typo in a key is a build error. See Messages for the full rules.

The manifest is the plugin’s description: its name, the kinds of items it adds and its screens. Sections the plugin does not use are still listed, as empty arrays.

plugins/houseplants/manifest/plugin.ts
import { CLIENT_API_VERSION, definePlugin } from "@ryot-app/contract/modules/plugins/manifest";
import { catalogMessage } from "../shared/messages.generated";
import { PLUGIN_PACKAGE_ID } from "../shared/plugin-identity";
const page = (entry: string) => ({
entry,
kind: "page" as const,
settingsSchema: { fields: {} },
automaticEntityPresentations: false,
});
export default definePlugin({
crons: [],
hooks: [],
providers: [],
workflows: [],
operations: [],
savedViews: [],
signalSchemas: [],
importSources: [],
userBootstrap: [],
httpRateLimits: [],
relationshipSchemas: [],
integrationProviders: [],
configSchema: { fields: {}, unknownKeys: "strict" },
metadata: {
icon: "sun",
version: "0.1.0",
packageId: PLUGIN_PACKAGE_ID,
name: catalogMessage("plugin.name"),
description: catalogMessage("plugin.description"),
},
entitySchemas: [
{
slug: "plant",
icon: "sun",
eventSchemas: [],
editor: { deletable: true, relationships: [] },
name: catalogMessage("entity-schema.plant.name"),
propertiesSchema: {
fields: {
species: {
type: "string",
description: "The plant's species",
label: catalogMessage("property.species"),
},
wateringIntervalDays: {
type: "integer",
description: "How many days to wait between waterings",
label: catalogMessage("property.watering-interval"),
},
},
},
},
],
client: {
homeView: null,
apiVersion: CLIENT_API_VERSION,
routes: { "/": "home", "/new": "new-plant" },
entities: { plant: { detailPage: "plant-page" } },
exports: {
home: page("client/home.tsx"),
"new-plant": page("client/new-plant.tsx"),
"plant-page": page("client/plant-page.tsx"),
},
},
});

The important parts:

  • entitySchemas adds the Plant item type. Ryot calls items entities and their types entity schemas. Each plant has a name plus the two properties listed here.
  • editor lets people create, edit and delete plants with Ryot’s built-in form, so you do not have to write one.
  • client lists the screens. routes maps addresses inside the plugin to screens, and entities says which screen to show when someone opens a plant.
  • Each label is shown in forms. Each description is plain English for developers and AI tools, and is never shown in forms.

Plugin screens are React components. Each one is the default export of the file the manifest points to.

First, a recipe: a typed query that reads your plants. Queries are written in RyotQL, Ryot’s query language, with TypeScript helpers:

plugins/houseplants/client/plants-recipe.ts
import { Result, Schema } from "@ryot-app/plugin-client-sdk/effect";
import type { PluginIdentityReference } from "@ryot-app/plugin-client-sdk/plugin";
import {
ascending,
column,
defineRecipe,
entitySchemaPredicate,
jsonPath,
selectedField,
selectedRows,
table,
} from "@ryot-app/plugin-client-sdk/ryotql";
export const plantsRecipe = (plugin: PluginIdentityReference) => {
const plant = table("entity", "plant");
return defineRecipe({
map: ({ plants }) => Result.succeed(plants.items),
queries: {
plants: selectedRows(plant, {
limit: 100,
where: entitySchemaPredicate(plant, "plant", plugin),
orderBy: [ascending(column(plant, "name")), ascending(column(plant, "id"))],
selection: {
id: selectedField(column(plant, "id"), Schema.String),
name: selectedField(column(plant, "name"), Schema.String),
species: selectedField(
jsonPath(column(plant, "properties"), "species"),
Schema.NullOr(Schema.String),
),
},
}),
},
});
};

The home screen runs that query, lists each plant with a link to its page and has an Add plant button:

plugins/houseplants/client/home.tsx
import { PluginLink } from "@ryot-app/plugin-client-sdk/plugin";
import {
createRyotQuery,
useMessages,
useRyot,
useRyotQuery,
useStampedMessages,
} from "@ryot-app/plugin-client-sdk/react";
import { PluginScreenFrame } from "@ryot-app/plugin-client-sdk/screen";
import { Button, QueryStatus } from "@ryot-app/plugin-ui-sdk";
import { catalogMessage } from "../shared/messages.generated";
import { PLUGIN_PACKAGE_ID } from "../shared/plugin-identity";
import { plantsRecipe } from "./plants-recipe";
const plantsQuery = createRyotQuery(({ client }) =>
client.data.query(plantsRecipe(client.pluginIdentity(PLUGIN_PACKAGE_ID)), {}),
);
export default function Home() {
const ryot = useRyot();
const plants = useRyotQuery(plantsQuery);
const text = useMessages(PLUGIN_PACKAGE_ID, catalogMessage);
const message = useStampedMessages(PLUGIN_PACKAGE_ID, catalogMessage);
return (
<PluginScreenFrame
title={message("home.title")}
primaryAction={
<Button
onClick={() =>
ryot.navigation.push({
kind: "plugin-route",
packageId: PLUGIN_PACKAGE_ID,
path: "/new",
})
}
>
{text("home.add")}
</Button>
}
>
<QueryStatus query={plants} onRetry={plants.refetch}>
{(items) =>
items.length === 0 ? (
<p className="text-text-muted">{text("home.empty")}</p>
) : (
<ul className="flex flex-col gap-2">
{items.map((plant) => (
<li key={plant.id}>
<PluginLink to={{ kind: "entity", entityId: plant.id }}>
{text("home.plant", { name: plant.name, species: plant.species ?? "" })}
</PluginLink>
</li>
))}
</ul>
)
}
</QueryStatus>
</PluginScreenFrame>
);
}

The other two screens reuse Ryot’s built-in entity editor. One creates a plant:

plugins/houseplants/client/new-plant.tsx
import { EntityEditorScreen } from "@ryot-app/plugin-client-sdk/entity-editor";
import { PLUGIN_PACKAGE_ID } from "../shared/plugin-identity";
export default function NewPlant() {
return (
<EntityEditorScreen
packageId={PLUGIN_PACKAGE_ID}
entitySchemaSlug="plant"
mode={{ kind: "create" }}
/>
);
}

The other is the plant’s own page, where you can edit or delete it:

plugins/houseplants/client/plant-page.tsx
import { EntityEditorScreen } from "@ryot-app/plugin-client-sdk/entity-editor";
import { usePluginLocation } from "@ryot-app/plugin-client-sdk/plugin";
import { PLUGIN_PACKAGE_ID } from "../shared/plugin-identity";
export default function PlantPage() {
const location = usePluginLocation();
if (location.kind !== "entity") {
return null;
}
return (
<EntityEditorScreen
packageId={PLUGIN_PACKAGE_ID}
entitySchemaSlug="plant"
mode={{ kind: "edit", entityId: location.entityId }}
/>
);
}

Class names such as text-text-muted are Tailwind utilities that use Ryot’s colors, so your screens match the app in light and dark mode.

  1. From the repository root, run bun install again so the workspace picks up your new package.

  2. Build the plugin and everything it depends on:

    Terminal window
    bun turbo build --filter=houseplants-plugin

    The build checks the manifest, type-checks and compiles your code, validates your queries and messages, and writes the archive to plugins/houseplants/dist/yourname/houseplants.zip.

  3. After the first build, you can rebuild from the plugin folder with bun run build.

If something is wrong, the build stops and prints the file, line and reason.

  1. In Ryot, open Settings → Plugins, choose Install plugin and pick houseplants.zip. See Install a private plugin for every step.

  2. Wait until the plugin shows Ready. Choose Refresh to check.

  3. Open the workspace switcher at the top of the sidebar and choose Houseplants. You see My plants and “No plants yet.”

  4. Choose Add plant, fill in Name, Species and Water every (days), and choose Save. Ryot opens the new plant’s page.

  5. Go back to My plants. Your plant is in the list.

  1. Edit your code.

  2. Raise version in the manifest, for example to 0.1.1.

  3. Run bun run build in plugins/houseplants.

  4. In Settings → Plugins, select Houseplants, choose Update package and pick the new archive. Your plants are kept.

ryot: command not found or “Could not resolve” errors. Run bun install from the repository root after you create or change package.json.

“Invalid package.json” or package.json must define exports["."].default. The exports entry must be an object with a default key, exactly as in step 2.

“Invalid plugin manifest” with Missing key. Every manifest section must be present, even when empty. Copy the manifest above and change only what you need. The manifest reference lists every section.

A message key error. Every catalogMessage("...") and text("...") key must exist in en.json, and every key in en.json must be used somewhere.

“Entity page not registered” when you open a plant. The manifest’s client.entities must name a detail page for the schema, as plant-page does here.

  • Add an action that records when you water a plant: Backend code.
  • Learn the parts of a plugin: How plugins work.
  • Read real plugins in the repository: plugins/fixture (Ryot’s test plugin, which touches most features), plugins/fitness and plugins/media.