К основному содержанию
скилл CX Codex

render-functions — скилл для Claude Code: что делает и как установить

Скилл render-functions учит ИИ-агента писать рендер-функции через h() и синтаксис JSX во Vue. Пригодится при сборке UI-библиотек и динамической разметки, где возможностей шаблонов не хватает.

MIT 196 установок ★ 259 обновлён 2026-04-15

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add PatternsDev/skills --skill render-functions -a claude-code
Открыть на GitHub

Что делает render-functions

Скилл объясняет агенту, как создавать компоненты Vue программно с помощью функции h() и JSX вместо привычной секции <template>. Шаблонный синтаксис компилируется в виртуальные узлы DOM ещё при сборке. Прямой вызов рендер-функций обходит этот этап и даёт полный контроль над виртуальным DOM в коде JavaScript.

Внутри описаны правила передачи трёх аргументов в h(): тег или компонент, свойства с обработчиками событий и дочерние элементы. Для работы с JSX во Vue обязательно требуется настроить @vue/babel-plugin-jsx, потому что из коробки поддержка JSX отсутствует. В отличие от React, здесь применяется атрибут class, а переменные оборачиваются в одинарные фигурные скобки.

Инструкция рекомендует оставлять стандартные шаблоны везде, где хватает директив v-if, v-for или слотов. Переходить на ручные рендеры имеет смысл только для динамических компонентов в библиотеках или сложных условий отображения.

Какие задачи решает

  • переписать шаблон Vue на вызовы функции h()
  • настроить JSX для динамических компонентов Vue
  • создать элементы библиотеки компонентов со сложной динамической структурой
  • реализовать программную генерацию виртуального DOM

Примеры запросов агенту

  • Перепиши этот компонент карточки с <template> на функцию h() из Vue.
  • Сделай динамический заголовок во Vue через JSX вместо директив v-if.
  • Покажи, как передать пропсы и дочерние элементы в h() для компонента кнопки.

Как установить render-functions

1Через Skills CLI (Vercel)

npx skills add PatternsDev/skills --skill render-functions -a claude-code

2Вручную: положить файлы

~/.claude/skills/render-functions/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/render-functions/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о render-functions

Как установить render-functions в Claude Code?

Выполните команду npx skills add PatternsDev/skills --skill render-functions -a claude-code. Файл навыка сохранится по пути ~/.claude/skills/render-functions/SKILL.md.

Зачем нужны рендер-функции вместо обычных шаблонов Vue?

Рендер-функции дают прямой доступ к созданию виртуального DOM на чистом JavaScript. Они полезны для гибких библиотек компонентов и сценариев, когда логику отображения неудобно выразить директивами вроде v-if.

Что требуется для использования JSX во Vue?

Vue требует подключить Babel-плагин @vue/babel-plugin-jsx. Также важно помнить синтаксические отличия: во Vue JSX пишется class вместо className, а переменные вставляются в одинарных фигурных скобках {}.

Исходный текст

SKILL.md · MIT
---
name: render-functions
description: Teaches Vue render functions and JSX for programmatic template creation. Use when templates are too limiting and you need the full power of JavaScript to construct component output dynamically.
paths:
  - "**/*.vue"
license: MIT
metadata:
  author: patterns.dev
  version: "1.1"
related_skills:
  - "composables"
  - "components"
---

# Render Functions

## Table of Contents

- [When to Use](#when-to-use)
- [When NOT to Use](#when-not-to-use)
- [Instructions](#instructions)
- [Details](#details)
- [Source](#source)

Vue recommends for us to use templates (i.e. the `<template></template>` syntax) to construct the markup of our Vue components. However, we're also given the opportunity to directly use something known as **render functions** to build the markup of our components as well.

Vue, at build time, takes the templates we create for our components and compiles them to render functions. It's at these compiled render functions, where Vue builds a virtual representation of nodes that make up the virtual DOM.

## When to Use

- Use this when you need complex dynamic rendering logic that's hard to express with template directives
- This is helpful for component library development where flexibility and low-level control are needed

## When NOT to Use

- When templates handle the use case — templates are more readable and benefit from compile-time optimizations
- For standard component markup where `v-if`, `v-for`, and slots cover the rendering needs
- When the team is unfamiliar with `h()` / JSX and the maintenance cost outweighs the flexibility gain

## Instructions

- Use the `h()` function with three arguments: tag/component, props/attributes, and children
- Use JSX with `@vue/babel-plugin-jsx` as a more readable alternative to raw `h()` calls
- Prefer Vue templates for most application code — render functions are for advanced cases
- Remember that Vue JSX uses `class` (not `className`) and single curly braces `{}`

## Details

By using render functions, we skip the compile step that Vue takes to compile our templates, and are able to construct our component templates with the help of programmatic JavaScript.

### But why?

Render functions come into play when we require a higher level of customization and flexibility that's not easily achievable with the standard template syntax. In a nutshell, you may prefer to use render functions:

- When you need to dynamically render components or elements based on complex logic that can be cumbersome to express within a template.
- You want to have a direct hand on the Virtual DOM for advanced manipulations.
- You want to use JSX for building the template of your components.

Outside of these unique cases, Vue's template syntax should remain the go-to method for constructing component markup.

### Render functions

Assume we had the following component that contains a `<div>` element encompassing a `<header>` element. The text content of the `<header>` element simply displays the value of a `message` prop.

```html
<template>
  <div class="render-card">
    <header class="card-header card-header-title">{{ message }}</header>
  </div>
</template>

<script setup>
  const { message } = defineProps(["message"]);
</script>
```

We'll recreate the markup of the component step by step with the help of the render function — i.e. the `h()` function.

`h` is short for **hyperscript** which is a term often used in virtual DOM implementations to denote JavaScript syntax that produces HTML. In simple terms, the `h()` function is the render function that allows us to create the "virtual" representation of the DOM nodes that Vue uses to track and subsequently render on the page.

The `h()` function takes three arguments of its own:

1. An HTML tag name or a component definition.
2. The props/attributes to be passed onto the element (event listeners, class attributes, etc.).
3. Child nodes of the parent node.

Here's the full render function equivalent:

```html
<template>
  <render />
</template>

<script setup>
  import { h } from "vue";

  const { message } = defineProps(["message"]);

  const render = () => {
    return h(
      "div",
      {
        class: "render-card",
      },
      [
        h(
          "header",
          {
            class: "card-header card-header-title",
          },
          message
        ),
      ]
    );
  };
</script>
```

We can now render the above component in the parent `App.vue` instance and pass a value of `"Hello World!"` to the `message` prop.

```html
<template>
  <RenderComponent message="Hello world!" />
</template>

<script setup>
  import RenderComponent from "./components/RenderComponent.vue";
</script>
```

The component constructed with a render function produces the exact same output to its template equivalent.

### JSX

JSX is a syntax extension that allows us to write HTML-like code within JavaScript. With Vue, JSX can be used as an alternative to the `h()` function to construct render functions.

Vue's JSX support isn't built in like in React. We need to use a specific Babel plugin — [`@vue/babel-plugin-jsx`](https://github.com/vuejs/babel-plugin-jsx) — to have our JSX code transformed into the appropriate `h()` function calls.

Here's the same render function component we've built before but now recreated with JSX:

```jsx
<script setup>
  const { message } = defineProps(["message"]);

  const render = () => {
    return (
      <div class="render-card">
        <header class="card-header card-header-title">{message}</header>
      </div>
    );
  };
</script>
```

Since JSX is closer to JavaScript than to HTML, Vue JSX components use `class` instead of `className` and variables are embedded with single curly braces `{}` instead of double curly braces `{{ }}`.

### When to use render functions

- If your component has complex, conditional rendering logic that is hard to express with template directives, render functions (with or without JSX) can provide a cleaner solution.
- If you want more direct control over the virtual DOM.
- In library/component-kit development where flexibility and low-level control are needed.

For most typical application development, Vue templates offer the right level of expressiveness and readability. Render functions and JSX are powerful tools to reach for when templates aren't enough.

## Source

- [patterns.dev/vue/render-functions](https://patterns.dev/vue/render-functions)

### References

- [Render Functions & JSX | Vue Documentation](https://vuejs.org/guide/extras/render-function.html)
- [`@vue/babel-plugin-jsx` | GitHub](https://github.com/vuejs/babel-plugin-jsx)

© patterns.dev · MIT · PatternsDev/skills

Похожие скиллы

Все скиллы по теме «Фронтенд и UI» →
rendering-conditional-render tech-leads-club Правило rendering-conditional-render предотвращает случайный рендер нулей и NaN в JSX. Использует явные тернарные операторы вместо && для проверок, чтобы falsy-значения не попадали в DOM. CX Codex +1 ★ 7 191звёзд репо tailwindcss-development laravel Скилл tailwindcss-development пишет и правит Tailwind-классы в Blade, JSX и Vue. Срабатывает сам, когда в запросе встречается слово tailwind. CX Codex +1 1 000установок vueuse-functions SerKo Скилл vueuse-functions подбирает функции VueUse для задач во Vue.js и Nuxt и помогает применять их вместо собственного кода. Подходит для Vue 3+ и Nuxt 3+. CX Codex +1 4 100установок json-render-generative-ui reason-machines Скилл json-render-generative-ui учит нейросеть собирать интерфейсы через json-render: модель выдаёт строгий JSON-манифест, а приложение отрисовывает его в React, Vue или PDF. CX Codex +1 1 300установок solidjs sanjeed5 Правило задаёт практики для SolidJS 1.x: реактивность, компоненты, состояние и очистка ресурсов. Применяется к JavaScript и JSX-файлам. CX Codex +1 ★ 3 589звёзд репо htmx sanjeed5 Набор инструкций для Cursor по работе с htmx. Задаёт правила декларативной вёрстки, частичных ответов сервера и запрещает лишний JavaScript для сетевых запросов. CX Codex +1 ★ 3 589звёзд репо

Из того же набора58

Весь набор →
async-components Скилл async-components учит агента загружать Vue-компоненты асинхронно через defineAsyncComponent(), чтобы не тянуть тяжёлые модалки и диалоги при старте. CX Codex +1 207установок container-presentational Скилл container-presentational учит разделять Vue-компоненты на контейнеры (логика, запросы) и презентационные (вёрстка). Презентационный компонент получает данные через props и не трогает состояние. CX Codex +1 205установок data-provider Объясняет паттерн data provider во Vue: логика загрузки и состояния передаётся дочерним компонентам через scoped slots. CX Codex +1 204установок state-management Скилл state-management направляет агента при проектировании реактивного состояния во Vue 3. Помогает выбрать между props, простым хранилищем на reactive() и Pinia. CX Codex +1 201установок dynamic-components Скилл dynamic-components для Claude Code переключает компоненты Vue через <component :is> и сохраняет их состояние с <KeepAlive>. Переключает вкладки и панели без роутера. CX Codex +1 198установок provide-inject Скилл provide-inject учит агента использовать provide() и inject() из Vue для передачи данных глубоко вложенным компонентам без прокидывания пропсов через каждый уровень. CX Codex +1 196установок script-setup Учит агента писать Vue 3-компоненты с <script setup> — без лишнего кода и явного return. CX Codex +1 195установок renderless-components Скилл renderless-components учит паттерну renderless-компонентов во Vue: логика отдельно, разметка — на вызывающий код через scoped slots. CX Codex +1 194установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой