
Vue Jsx Best Practices
- 2.1k installs
- 2.8k repo stars
- Updated May 30, 2026
- hyf0/vue-skills
This is a copy of vue-jsx-best-practices by vuejs-ai - installs and ranking accrue to the original listing.
vue-jsx-best-practices is a Vue 3 coding skill that prevents React-style attribute mistakes like className and htmlFor when writing JSX or TSX components with standard HTML attribute names in Vue render functions.
About
vue-jsx-best-practices is a gotcha-focused skill from hyf0/vue-skills rated MEDIUM impact for Vue 3 teams using JSX or TSX render functions in Cursor or Claude Code. Vue's JSX transform expects standard HTML attribute names such as class and for, not React conventions like className and htmlFor; with proper TypeScript configuration, React-style names trigger TypeScript errors that catch inconsistencies early. The skill tags cover vue3, jsx, tsx, and render-function workflows. Frontend developers reach for vue-jsx-best-practices when migrating React JSX habits into Vue 3 or debugging TSX attribute type failures in Vue components.
- Enforces HTML attributes (class, for) instead of React conventions (className, htmlFor)
- Prevents TypeScript errors in Vue JSX projects
- 5-point task checklist for consistent Vue render functions
- Migration guidance when converting React components to Vue
- Works with proper TypeScript configuration for Vue JSX
Vue Jsx Best Practices by the numbers
- 2,086 all-time installs (skills.sh)
- +23 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/hyf0/vue-skills --skill vue-jsx-best-practicesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2.1k |
|---|---|
| repo stars | ★ 2.8k |
| Security audit | 3 / 3 scanners passed |
| Last updated | May 30, 2026 |
| Repository | hyf0/vue-skills ↗ |
Why do className and htmlFor fail in Vue 3 JSX?
Eliminate React-style attribute mistakes when writing Vue 3 JSX or TSX components with Cursor or Claude.
Who is it for?
Frontend developers writing Vue 3 JSX or TSX render functions who keep defaulting to React attribute naming conventions.
Skip if: Teams using Vue Single-File Components with template syntax only and no JSX or TSX render functions.
When should I use this skill?
The user writes Vue 3 JSX/TSX, hits TypeScript errors on className or htmlFor, or asks about Vue render-function attribute conventions.
What you get
Vue 3 JSX/TSX components using HTML attribute names with passing TypeScript checks
- Corrected JSX/TSX attribute usage
- TypeScript-clean Vue render functions
By the numbers
- Rated MEDIUM impact for preventing React-style attribute mistakes in Vue JSX
Files
Vue JSX best practices and differences from React JSX.
JSX
- Migrating React JSX code to Vue or getting attribute type errors → See render-function-jsx-vue-vs-react
Vue JSX Uses HTML Attributes Not React Conventions
Impact: MEDIUM - Vue's JSX transform uses standard HTML attribute names (class, for) instead of React's JavaScript-friendly names (className, htmlFor). With proper TypeScript configuration, using React conventions like className or htmlFor will produce TypeScript errors, which is good for catching these inconsistencies early. Note that Vue's runtime is lenient and will actually convert these attributes correctly, but using HTML attributes is the recommended practice for consistency with Vue templates and proper type safety.
When writing JSX in Vue, use the same attribute names you would use in regular HTML templates. This is a fundamental difference from React's JSX where class and for are reserved JavaScript keywords.
Task Checklist
- [ ] Use
classinstead ofclassNamein Vue JSX - [ ] Use
forinstead ofhtmlForin Vue JSX - [ ] Use standard HTML event names with
onprefix (onClick, onInput) - [ ] When migrating React components to Vue, update all attribute names
- [ ] Configure TypeScript properly for Vue JSX type inference
Incorrect (React-style):
// AVOID: React conventions cause TypeScript errors in Vue JSX
// (Vue runtime is lenient and converts these, but types don't allow them)
export default {
setup() {
return () => (
<div className="container">
<label htmlFor="email">Email:</label>
<input id="email" className="input-field" />
</div>
)
}
}// AVOID: TypeScript will reject className/htmlFor with Vue's JSX types
const Button = () => (
<button
className="btn btn-primary" // TS error: Property 'className' does not exist
htmlFor="form" // TS error: Property 'htmlFor' does not exist
>
Submit
</button>
)Correct (Vue-style):
// CORRECT: Use standard HTML attributes
export default {
setup() {
return () => (
<div class="container">
<label for="email">Email:</label>
<input id="email" class="input-field" />
</div>
)
}
}// CORRECT: Vue TSX with HTML attributes
const Button = () => (
<button
class="btn btn-primary"
>
Submit
</button>
)TypeScript Configuration for Vue JSX
To enable proper type inference and IntelliSense for Vue JSX/TSX, configure your tsconfig.json:
{
"compilerOptions": {
"jsx": "preserve",
"jsxImportSource": "vue"
}
}Starting from Vue 3.4, Vue no longer implicitly registers the global JSX namespace, so jsxImportSource is required for TypeScript to use Vue's JSX type definitions.
Vite Configuration
For Vite projects, ensure you have the JSX plugin configured in vite.config.ts:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
export default defineConfig({
plugins: [vue(), vueJsx()]
})Other Attribute Differences
| React JSX | Vue JSX | HTML |
|---|---|---|
| className | class | class |
| htmlFor | for | for |
| onChange | onInput (for live updates) | oninput |
| tabIndex | tabindex | tabindex |
| readOnly | readonly | readonly |
Event Handling in Vue JSX
// Vue JSX event handling
export default {
setup() {
const handleClick = () => console.log('clicked')
const handleInput = (e) => console.log(e.target.value)
return () => (
<div>
<button onClick={handleClick}>Click</button>
<input onInput={handleInput} />
{/* Event modifiers via helper */}
<div onClick={withModifiers(handleClick, ['self'])}>
Only triggers on self
</div>
</div>
)
}
}Reference
Related skills
How it compares
Use vue-jsx-best-practices specifically for Vue 3 JSX/TSX attribute conventions rather than general Vue SFC or React JSX skills.
FAQ
Should Vue 3 JSX use className or class?
vue-jsx-best-practices requires standard HTML attribute names in Vue 3 JSX: use class and for instead of React's className and htmlFor to satisfy Vue's JSX transform and TypeScript checks.
Does Vue runtime accept React-style JSX attributes?
Vue's runtime can be lenient with React-style names, but vue-jsx-best-practices warns that proper TypeScript configuration surfaces className and htmlFor as errors, which helps catch inconsistent JSX early.
Is Vue Jsx Best Practices safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.