Skip to content

How plugins work

This page explains the moving parts of a plugin in plain words: what you write, what the build produces and where each piece runs. Read it after the quick start and before you build something bigger.

A plugin is a package with up to four source folders. Each folder runs in a different place, so each has its own rules about what it may import.

  • Directoryplugins/my-plugin
    • package.json
    • Directorymanifest/ the description of the plugin, read by the Ryot server and app
      • …
    • Directoryshared/ code and text used everywhere
      • Directorymessages/
        • en.json
    • Directorybackend/ code that runs on the server, in a sandbox
      • Directoryoperations/
        • do-something.sandbox.ts
    • Directoryclient/ screens that run in the browser, in an isolated frame
      • home.tsx
Folder What goes in it Where it runs
manifest/ The manifest: the plugin’s name, data types, screens, actions, views, imports and so on. Read by Ryot when it installs
shared/ Text catalogs, schemas and query recipes that both the backend and the client use. Bundled into the backend and client
backend/ Server-side scripts: actions, automations, imports, integrations, metadata providers, scheduled jobs. The server’s plugin sandbox
client/ React screens and components. A sandboxed frame in the Ryot app

Only the manifest and the English message catalog are required. A plugin can have no screens (for example an importer) or no backend code (like the quick start plugin).

Code in backend/, client/ and shared/ never imports from manifest/. Put anything both sides need in shared/, which may only import from a small, environment-neutral set of helpers. The package layout reference has the exact rules.

ryot plugin build turns the package into one .zip archive. It:

  1. Checks your message catalogs and generates the typed catalogMessage builder.
  2. Loads and validates the manifest.
  3. Finds every backend/**/*.sandbox.ts file and compiles it into a sandbox script.
  4. Compiles the screens and components the manifest lists.
  5. Validates your data types, queries and views against Ryot’s own definitions.
  6. Writes a deterministic archive to dist/<publisher>/<name>.zip.

The archive holds compiled code, the manifest and the compiled message catalogs, not your source files. When someone installs it, the server checks the archive’s structure and hashes, stores it and finishes setting the plugin up in the background. See the CLI reference.

The manifest is a TypeScript file whose default export is definePlugin({ ... }). It is data, not code that runs: Ryot reads it to learn what the plugin adds. Its main sections are:

  • Data: entitySchemas (kinds of items and their history), relationshipSchemas (links between items) and savedViews (views in the sidebar). See Data model.
  • Screens: the client section maps addresses and item types to the React files in client/. See Screens.
  • Server-side behavior: operations, hooks, crons, workflows, providers, importSources and integrationProviders, each pointing at scripts in backend/. See Backend code.
  • Settings: configSchema for settings people fill in when they install, and userSettingsSchema for preferences under Settings → Plugin preferences.

Every array section must be present, even when it is empty. The manifest reference covers every section.

Your client code runs in a sandboxed <iframe> inside the Ryot app. The frame has no access to the rest of the app, the user’s session or localStorage. It talks to Ryot through a message bridge that the client SDK wraps for you:

  • client.data.query reads data with a query.
  • client.operations.invoke runs one of your plugin’s actions.
  • ryot.navigation and PluginLink move between screens and items.
  • client.uploads, usePluginStorage and usePluginUserSettings handle files, per-device storage and the user’s plugin preferences.

You write ordinary React components and default-export them. You never mount or bootstrap an app: the compiler generates that. Ryot tells your screens about the layout (such as whether the screen is compact) instead of the frame measuring itself, so do not rely on CSS media queries.

Each *.sandbox.ts file default-exports one definition, such as defineOperation or defineAutomation, with an input schema, an output schema and a run function. Every run happens in a fresh, isolated JavaScript engine with strict limits on time, memory and the number of calls it makes.

Backend code has no direct access to the database, files or network. It asks Ryot through a host object, for example host.executeRyotql to run a query or host.httpCall to fetch a URL. Host calls only read. To change data, a script returns the changes it wants, and Ryot checks them and saves them all at once after the run. The compiler works out which host capabilities each script uses, so you never declare permissions by hand.

Everything a plugin stores fits Ryot’s shared data model:

  • Entities are items, such as a movie, an exercise or a plant. Each has a name and properties that follow its entity schema.
  • Events are history on an entity, such as “watched” or “watered”, with a time and properties.
  • Relationships link two entities, such as an episode to its show.

You read all of it with RyotQL, Ryot’s typed query language, by building recipes with TypeScript helpers. The same recipe runs from a screen (client.data.query) or from backend code (executeRyotqlRecipe). See the queries reference.

Plugins never send finished English sentences to Ryot. Every label and message is a key in shared/messages/<locale>.json, created with catalogMessage("key") and rendered in the reader’s language at the last moment. This is why manifest labels are catalogMessage(...) calls, and why screens use useMessages to turn keys into text. See Messages.

The SDKs are built on Effect, a TypeScript library for typed, composable asynchronous code. Backend run functions return an Effect, and client queries and actions are defined with Effect-returning callbacks. For simple code, Effect.succeed(value) and Effect.gen(function* () { ... }) are all you need.

A plugin’s package ID (publisher/name) is permanent and identifies it everywhere. Ryot also records whether an installation is a system plugin (shipped with the server, shared by everyone) or a private plugin (installed by one person, visible only to them). Your code does not choose this: Ryot decides it at install time. Private plugins cannot write shared catalog data or declare server-wide settings such as HTTP rate limits.

A plugin can also build on another plugin by declaring it in dependencies, which lets it import that plugin’s public components and refer to its data types in queries. See Package layout.