Skip to main content

Frontend

Your frontend exports activate(app). Termix loads it after sign in and calls it with app, which is how you add things to the UI.

import type { TabProps, TermixApp } from "@termix-ssh/plugin-sdk/frontend";
import { useTranslation } from "@termix-ssh/plugin-sdk/frontend";
import { PanelShell } from "@termix-ssh/plugin-sdk/ui";
import { Hand } from "lucide-react";

function HelloTab(_props: TabProps) {
const { t } = useTranslation();
return (
<PanelShell icon={<Hand className="size-4" />} title={t("tab.title")}>
<p className="p-4">{t("tab.empty")}</p>
</PanelShell>
);
}

export function activate(app: TermixApp) {
app.registerRailItem({
id: "hello",
icon: Hand,
titleKey: "tab.title",
kind: "tab",
});
app.registerTab("hello", HelloTab, {
icon: Hand,
titleKey: "tab.title",
singleton: true,
hostless: true,
});
}

Every register* call returns a function that undoes it, and everything is undone when the plugin is disabled. Every component you register runs inside your plugin's scope, an error boundary and Suspense, so a crash stays in your box.

What app has​

MemberWhat it does
registerRailItemA button in the sidebar rail.
registerTab, registerPanelA tab type or a sidebar panel. The id must be in contributes.tabs or contributes.panels.
registerDashboardCardA dashboard card, declared in contributes.dashboardCards.
registerHostActionAn action on a host: a button, a palette entry, the default connect.
registerHostEditorSectionYour own section in the host editor. Most plugins don't need it, since host settings get one for free.
registerHostProtocolA connection protocol next to SSH.
registerHostBadge, registerHostContextMenuItemBadges and menu items on host rows.
registerPaletteEntry, registerPaletteGroupCommand palette entries.
registerKeybindingAction, registerKeybindingDefaultThings keys can be bound to.
registerSettingsComponentA component for a custom settings field.
registerAction, invokeActionCall and answer actions across plugins.
registerSlotContribution, declareActionSlotFill slots other plugins own, or own one. See more extension points.
registerComponentOffer a component other plugins render by id.
registerExtensionAdd an item to a named list another plugin reads.
registerOnboardingStepA step in first-run setup.
registerLoginMethod, registerSecondFactorUI, registerSshAuthEditorSign in UI. See auth.
apiAn axios client for your /plugin-api/<id>/ routes, with auth.
fetch(path)A raw fetch to your routes, for streamed responses.
wsUrl(path)The URL and auth for one of your sockets.
docsLinks into your own docs. See writing docs.
tabsOpen, close and read tabs.
confirmAsk a yes or no question.
listHosts, getHostHosts the user can see.
t, hasPermissionStrings and permission checks outside a component.
desktopWhether you run in the desktop app, and the server it is linked to.
onSettingsChanged, onDisposeHooks.

Hooks​

Inside your components, from @termix-ssh/plugin-sdk/frontend:

HookWhat it gives you
useTranslation()t for your own strings.
usePermission("use")Whether the user has <your id>.use.
useSettings("user")Your settings and a save.
useHost(id), useHosts()Hosts, with only your own host settings on them.
usePluginApi()The same client as app.api.
useCurrentUser(), useTheme(), useToast()The user, the theme and toasts.
useDocsUrl(page)A link to a page of your docs.
useTabs(), useSlotContributions(), useSshAuthTypes()Tabs, slot contents and SSH auth types.

Styling​

Build your UI from the UI kit so it looks like the rest of Termix and follows the theme. Tailwind classes work: termix-plugin build compiles the ones you use against Termix's theme into dist/frontend.css.

Shared packages​

These come from Termix, so you never ship a second copy: react, react-dom, i18next, react-i18next, sonner, @termix-ssh/plugin-sdk/frontend and @termix-ssh/plugin-sdk/ui. Anything else, like lucide-react, is bundled into your plugin.

Hosts in the browser​

A host your code receives carries only your own plugin's host settings, under host.pluginSettings[<your id>]. To read another plugin's setting, ask that plugin through an action or a service.