Docs

Creating Your First Extension

Sliprail validates an extension's registered ID, manifest, entry file, and default export before loading it.

Register the Extension

All public and private extensions need an ID from the Sliprail Developer Portal.

  1. Open the Developer Portal
  2. Create a Sliprail extension
  3. Choose public or private visibility
  4. For a public extension, provide the public GitHub repository URL
  5. Copy the generated extension ID

Create manifest.json

The following fields are required for an extension manifest:

  • id
  • displayName
  • description
  • main

icon is optional. displayName and description can be a string or a language map.

{
  "id": "your-registered-extension-id",
  "displayName": {
    "en": "Hello Sliprail",
    "zh-hans": "你好 Sliprail"
  },
  "description": {
    "en": "Copies a greeting to the clipboard",
    "zh-hans": "将问候语复制到剪贴板"
  },
  "main": "main.mjs",
  "icon": "icon.svg"
}

The main path is relative to the directory containing manifest.json and must point to an existing JavaScript module.

Create the Entry Module

import type { Extension } from '@sliprail/sdk'

const extension: Extension = {
  shortcuts: [
    {
      id: 'hello-sliprail',
      displayName: {
        en: 'Hello Sliprail',
        'zh-hans': '你好 Sliprail',
      },
      handle: (context) => {
        context.writeTextToClipboard('Hello from Sliprail')
        context.showNotification({
          title: 'Hello Sliprail',
          message: 'The greeting was copied to the clipboard',
        })
      },
    },
  ],
}

export default extension

Sliprail imports the file referenced by main and reads its default export. A named export alone will not load as an extension.

If the source file is TypeScript, build it to the JavaScript path referenced by main before loading the project directory.