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.
Before you start
Section titled “Before you start”You need:
1. Get the Ryot source code
Section titled “1. Get the Ryot source code”-
Clone the repository:
Terminal window git clone https://github.com/IgnisDa/ryot.gitcd ryot -
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.”
-
Install the dependencies:
Terminal window bun install
2. Create the plugin package
Section titled “2. Create the plugin package”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:
{ "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:*" }}3. Give it an identity
Section titled “3. Give it an identity”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.
import { PluginPackageId } from "@ryot-app/plugin-kit/schema";
export const PLUGIN_PACKAGE_ID = PluginPackageId.make("yourname/houseplants");4. Write its text
Section titled “4. Write its text”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:
{ "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.
5. Write the manifest
Section titled “5. Write the manifest”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.
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:
entitySchemasadds the Plant item type. Ryot calls items entities and their types entity schemas. Each plant has a name plus the twopropertieslisted here.editorlets people create, edit and delete plants with Ryot’s built-in form, so you do not have to write one.clientlists the screens.routesmaps addresses inside the plugin to screens, andentitiessays which screen to show when someone opens a plant.- Each
labelis shown in forms. Eachdescriptionis plain English for developers and AI tools, and is never shown in forms.
6. Build the screens
Section titled “6. Build the screens”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:
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:
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:
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:
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.
7. Build the archive
Section titled “7. Build the archive”-
From the repository root, run
bun installagain so the workspace picks up your new package. -
Build the plugin and everything it depends on:
Terminal window bun turbo build --filter=houseplants-pluginThe 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. -
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.
8. Install and try it
Section titled “8. Install and try it”-
In Ryot, open Settings → Plugins, choose Install plugin and pick
houseplants.zip. See Install a private plugin for every step. -
Wait until the plugin shows Ready. Choose Refresh to check.
-
Open the workspace switcher at the top of the sidebar and choose Houseplants. You see My plants and “No plants yet.”
-
Choose Add plant, fill in Name, Species and Water every (days), and choose Save. Ryot opens the new plant’s page.
-
Go back to My plants. Your plant is in the list.
Make a change
Section titled “Make a change”-
Edit your code.
-
Raise
versionin the manifest, for example to0.1.1. -
Run
bun run buildinplugins/houseplants. -
In Settings → Plugins, select Houseplants, choose Update package and pick the new archive. Your plants are kept.
Troubleshooting
Section titled “Troubleshooting”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.
Next steps
Section titled “Next steps”- 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/fitnessandplugins/media.