🎯

zhin-component-rendering

🎯Skill

from zhinjs/ai-skills

VibeIndex|
What it does

Renders reusable message UI components in Zhin using defineComponent, enabling dynamic template composition and message rendering.

πŸ“¦

Part of

zhinjs/ai-skills(5 items)

zhin-component-rendering

Installation

πŸ“‹ No install commands found in docs. Showing default command. Check GitHub for actual instructions.
Quick InstallInstall with npx
npx skills add zhinjs/ai-skills --skill zhin-component-rendering
1Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

Covers Zhin component rendering, defineComponent usage, and message template composition. Use when creating reusable message UI components.

Overview

# Zhin Component Rendering Skill

Use this skill when developers need to create reusable message components with Zhin's component system.

Define and Register a Component

```ts

import { defineComponent, usePlugin } from '@zhin.js/core'

const plugin = usePlugin()

const StatusCard = defineComponent((props: { title: string, value: string }, context) => {

return ${props.title}: ${props.value}

}, 'status-card')

plugin.addComponent(StatusCard)

```

Template Usage

Components render within message templates:

```ts

await message.$reply('')

```

You can nest components:

```ts

await message.$reply('')

```

Props & Expressions

Props support inline expressions with {} and template interpolation via ${} when rendering:

```ts

const Card = defineComponent((props: { title: string, count: number }) => {

return ${props.title}: ${props.count}

}, 'card')

await message.$reply('')

```

Rendering Lifecycle

The component service attaches a before.sendMessage listener to render templates before messages send.

If you need to pre-render a template manually, use renderComponents:

```ts

import { renderComponents } from '@zhin.js/core'

const options = await renderComponents(componentService.byName, {

context: 'process',

bot: 'dev',

type: 'private',

id: '123',

content: ''

})

```

Built-in Components

Zhin includes:

  • Fragment for grouping/children rendering
  • fetch for loading remote content (use carefully and validate URLs)

Best Practices

  • Keep components small and reusable.
  • Validate and sanitize user input before passing it into templates.
  • Avoid untrusted URLs with the fetch component.