YSX (YAML Syntax Extension) is a build-time transpiler that lets you write React components in YAML format. It provides a clean, declarative syntax that compiles to standard JSX/TSX at build time.
- ✅ Build-time transpilation - Zero runtime overhead
- ✅ Full React support - Hooks, state, props, events
- ✅ TypeScript ready - Type definitions included
- ✅ Webpack & Vite integration - Drop-in loaders available
- ✅ Hot reload support - Works seamlessly with dev servers
- ✅ Standalone CLI - Transpile files directly
- ✅ React 19 compatible - Uses latest React APIs
npm install ysx-core ysx-loader --save-dev// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.ysx$/,
use: [
'babel-loader',
'ysx-loader'
]
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.ysx']
}
};Create an App.ysx file:
---
name: App
imports:
- from: react
default: React
- from: ./logo.svg
default: logo
- from: ./App.css
render:
div:
className: App
children:
- header:
className: App-header
children:
- img:
src: !!js |
logo
className: App-logo
alt: logo
- p:
children:
- "Edit "
- code:
children: "src/App.js"
- " and save to reload."
- a:
className: App-link
href: "https://reactjs.org"
target: _blank
rel: noopener noreferrer
children: Learn ReactUse it in your app:
import App from './App.ysx';
function Main() {
return <App />;
}---
version: 1.0
name: ComponentName
# Explicit imports (recommended)
imports:
- from: react
default: React
named: [useState, useEffect]
- from: ./styles.css
- from: ./utils
default: helper
# Component hooks
hooks:
- useState:
variable: count
initialValue: 0
# Render tree
render:
div:
className: "container"
children: Hello WorldYSX supports explicit import declarations:
imports:
# Default + named imports
- from: react
default: React
named: [useState, useEffect, useMemo]
# Default import only
- from: ./MyComponent
default: MyComponent
# Named imports only
- from: lodash
named: [map, filter, reduce]
# Side-effect import (CSS, etc.)
- from: ./styles.cssIf no imports field is provided, YSX will auto-generate React imports based on hooks usage (backward compatible).
Use !!js for inline JavaScript expressions:
render:
button:
onClick: !!js |
() => console.log('Clicked!')
children: Click MeUse {variable} syntax for template strings:
render:
p: "Welcome, {props.username}!"render:
div:
children:
- h1: Title
- p: Paragraph text
- button:
onClick: !!js | () => handleClick()
children: Actionrender:
div:
style:
display: flex
padding: "10px"
backgroundColor: "#f0f0f0"
children: Styled contentTranspile YSX files directly:
npx ysx transpile src/Component.ysx output.jsx
npx ysx transpile src/Component.ysx output.tsx --typescript- ysx-core - Parser and transpiler
- ysx-loader - Webpack/Vite loader
- ysx-cli - Command-line tool
- ysx-types - TypeScript definitions
# Install dependencies
make install
# Build all packages
make build
# Run tests
make test
# Build example
make example# Version packages
npm run version
# Publish to NPM
npm run publishAdd to your tsconfig.json:
{
"compilerOptions": {
"types": ["ysx-types"]
}
}Contributions welcome! See CONTRIBUTING.md for guidelines.
MIT © 2026