Skip to content

Extensions

Example extension

extensions/example-hello: a free extension that uses every contribution point, and how to build it in and test it.

Last updated 2 min read Edit this page on GitHub
On this page

extensions/example-hello in the repository is a small free extension that uses every contribution point. Build it in:

Bash
USERTASKS_EXTENSIONS=./extensions/example-hello npm run build
npm run start
USERTASKS_EXTENSIONS=./extensions/example-hello npm run admin -- ext migrate

The last command creates its greetings table. Then enable Hello (example extension) in Settings → Extensions.

Layout#

FileEntryContents
usertasks-extension.json—The manifest
manifest.tsdefineExtension({ manifest, connectors })Client-safe: the manifest and the Hello Echo connector
server.tsdefineServerExtension({ … })Say Hello node, Greeting Received trigger, /greetings endpoints, /ping and /hooks/greeting public routes, an hourly digest job, a task.completed subscription, two MCP tools, the greetings migration, the loopback transport, UI actions and data sources, settings validation and lifecycle hooks
pages.tsxdefinePages({ '': …, new: …, digest: … })Custom pages
package.jsonusertasks.extensionNames the entry modules

What to try#

  • The Hello section in the sidebar (badge: greetings today) and Greeting digest under Operate.
  • + New → Greeting, and ⌘K Say hello to the team.
  • A task's … menu: Say hello to assignee (only when the task has an assignee) — the assignee gets a notification.
  • The Hello tab on a task, and the two widgets on Home.
  • Settings → Workspace → Hello: typed fields, an encrypted API token and certificate, Test connection.
  • In the workflow designer, the Hello palette group: the Greeting Received trigger and the Say Hello step.
  • POST /api/v1/ext/example-hello/greetings with an API key, and ext_example_hello_greet over MCP.

Testing an extension#

TypeScript
import { registerExtensionsForTest, resetExtensionsForTest } from '@/lib/extensions/testing'
import definition from '@/extensions/example-hello/manifest'
import server from '@/extensions/example-hello/server'

beforeEach(() => registerExtensionsForTest({ definitions: [definition], servers: [server] }))
afterEach(() => resetExtensionsForTest())

The framework's own tests (__tests__/extensions-*.test.ts) run every contribution point this way.

Styles#

Custom pages and UI may use any Tailwind utility class. The codegen writes lib/extensions/generated/extensions.css (imported by the global stylesheet, empty without extensions) with one Tailwind @source per extension directory, so classes used only inside an extension package — which Tailwind's automatic scan skips (node_modules, ignored paths) — are generated too.

Developing an extension package#

Production builds install the package (npm install <tarball | git URL | path>, a real directory in node_modules) and are built with USERTASKS_EXTENSIONS=<package> npm run build.

For development, link your working copy instead (a symlink, as npm link makes):

Bash
cd /path/to/usertasks
mkdir -p node_modules/@usertasks-ext && ln -s /path/to/my-extension node_modules/@usertasks-ext/my-extension
USERTASKS_EXTENSIONS=@usertasks-ext/my-extension npm run dev

Turbopack does not compile files outside the project, and a symlinked package would resolve its own imports (react/jsx-runtime …) from its real directory, where they are not installed. So the codegen detects a linked package and mirrors it into .usertasks-ext/<id>/ (git-ignored; .git, node_modules and dot-directories left out); the generated registry imports the mirror, which resolves through the project's own node_modules for next dev, next build and tsc alike. While next dev runs, changed files are copied into the mirror as you save them (if a server-side change does not show, restart next dev). Regenerating without the package (npm run extensions:gen) removes the mirror. A real install (npm install --install-links /path/to/my-extension) works too and is what production uses.

Was this page helpful?