{"id":47736070,"url":"https://github.com/vanityh/vanityh","last_synced_at":"2026-04-08T03:01:39.918Z","repository":{"id":348494353,"uuid":"1198130893","full_name":"VanityH/vanityh","owner":"VanityH","description":"VanityH – Elegant Hyperscript DSL for Frontend Render Functions","archived":false,"fork":false,"pushed_at":"2026-04-04T07:41:35.000Z","size":132,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-07T02:03:11.383Z","etag":null,"topics":["htm","html","hyperscript","jsx","tagged-template","template-literals","vanity-h","virtual-dom"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VanityH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-01T06:30:22.000Z","updated_at":"2026-04-05T16:49:02.000Z","dependencies_parsed_at":"2026-04-06T01:00:45.104Z","dependency_job_id":null,"html_url":"https://github.com/VanityH/vanityh","commit_stats":null,"previous_names":["vanityh/vanityh"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/VanityH/vanityh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VanityH%2Fvanityh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VanityH%2Fvanityh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VanityH%2Fvanityh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VanityH%2Fvanityh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VanityH","download_url":"https://codeload.github.com/VanityH/vanityh/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VanityH%2Fvanityh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31537791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"online","status_checked_at":"2026-04-08T02:00:06.127Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["htm","html","hyperscript","jsx","tagged-template","template-literals","vanity-h","virtual-dom"],"created_at":"2026-04-02T22:39:12.289Z","updated_at":"2026-04-08T03:01:39.862Z","avatar_url":"https://github.com/VanityH.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003e\n  VanityH\n  \u003ca href=\"https://www.npmjs.com/package/vanity-h\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/vanity-h.svg?style=flat\" alt=\"npm version\"\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\n[简体中文](./README_zh.md)\n\n### 🚀 VanityH: Make Hyperscript Elegant\n\n**Say goodbye to nesting hell, embrace fluent development experience**\n\nVanityH is not just another complex UI framework. It's a minimal **DSL (Domain-Specific Language) builder**. Using Proxy and closure logic, it transforms verbose `h(tag, props, children)` calls into a fluent, chainable syntax similar to **SwiftUI** or **Flutter**.\n\n---\n\n### 🎯 Core Problems VanityH Solves\n\nIn non-JSX environments (vanilla JS/TS, scripting tools, low-code engines), developers face these challenges:\n\n- **Nesting Hell**: Traditional `h` functions require heavy object nesting, creating visual noise\n- **Prop Mutation**: Component reuse often accidentally pollutes original definitions\n- **Cognitive Load**: Properties, events, and child nodes are interleaved, making DOM structure hard to understand\n- **Environment Dependencies**: JSX requires compilation setup, not suitable for lightweight use in native browser environments\n\n**VanityH perfectly resolves these issues with \"chainable configuration + terminator rendering\" logic.**\n\n---\n\n### ✨ Why Choose VanityH?\n\n#### 🎨 Structural Elegance\n\nVanityH separates property configuration from node mounting syntax, creating perfect mapping between code structure and DOM structure.\n\n```js\nhtml.lang(\"en\")(\n  head(\n    meta.charset(\"UTF-8\")(),\n    link.rel(\"icon\").type(\"image/svg+xml\").href(\"/favicon.svg\")(),\n    title(\"VanityH – Elegance Redefined\"),\n  ),\n  body(div.id(\"app\")(), script.type(\"module\").src(\"/src/main.ts\")()),\n);\n```\n\n#### 🔒 Fully Immutable Architecture\n\nBased on **Copy-on-Write** philosophy, each property call produces a brand-new state snapshot.\n\n```js\nconst baseBtn = button.class(\"btn\");\n\nconst redBtn = baseBtn.style(\"color: red\")(\"Red Button\");\nconst blueBtn = baseBtn.style(\"color: blue\")(\"Blue Button\"); // baseBtn remains pure\n```\n\n#### 🔍 Zero Magic Design\n\nTools should not be smarter than developers. VanityH doesn't auto-handle booleans, no implicit conversions, fully transparent.\n\n#### 📦 Ultra-Lightweight \u0026 Compatible\n\n- **Size**: Just 186 bytes, ultra-minimal implementation\n- **Compatibility**: Supports Vue, Preact, React, Snabbdom, and any hyperscript-compatible renderer\n\n---\n\n### 🚀 Quick Start\n\n#### Installation\n\n**NPM:**\n\n```bash\nnpm install vanity-h\n```\n\n**CDN (No Build Step Required):**\n\n```html\n\u003cscript type=\"module\"\u003e\n  // Using esm.sh (recommended) or unpkg\n  import { render, h } from \"https://esm.sh/preact\";\n  import createVanity from \"https://esm.sh/vanity-h\";\n  // Alternative: https://unpkg.com/vanity-h\n\n  const { div, span } = createVanity(h);\n\n  // Create UI with VanityH\n  const app = () =\u003e div.class(\"app\")(span(\"Hello World\"));\n\n  // Render to DOM\n  render(app(), document.getElementById(\"app\"));\n\u003c/script\u003e\n```\n\n#### Basic Usage (Vue 3)\n\n```typescript\nimport { h } from \"vue\";\nimport createVanity from \"vanity-h\";\n\n// Initialize and destructure needed tags\nconst { x, div, button, span, h1 } = createVanity(h);\n\n// 2. Wrap custom components\nimport MyComp from \"./MyComp.vue\";\n\n// Create UI\nconst app = div.class(\"app\").style(\"padding: 20px\")(\n  h1(\"VanityH Demo\"),\n  x(MyComp).theme(\"dark\").onClose(handleClose)(), // Use x wrapper\n  button.onClick(() =\u003e alert(\"Hello!\"))(\"Click Me\"),\n  span.style(\"color: blue\")(\"Experience elegant chaining\"),\n);\n```\n\n#### Try it in Playground\n\nExperience VanityH instantly in your browser:\n\n[![Try in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/vitejs-vite-bujruupx)\n\n#### Traditional vs VanityH Syntax\n\n```js\n// Traditional hyperscript\nh(\n  \"div\",\n  {\n    class: \"card\",\n    style: \"padding: 20px\",\n  },\n  [\n    h(\n      \"button\",\n      {\n        class: \"btn-primary\",\n        onClick: handleClick,\n      },\n      \"Click me\",\n    ),\n  ],\n);\n\n// VanityH syntax\ndiv.class(\"card\").style(\"padding: 20px\")(\n  button.class(\"btn-primary\").onClick(handleClick)(\"Click me\"),\n);\n```\n\n---\n\n### 🛠 Technical Implementation\n\nVanityH internally uses JavaScript's **Proxy** to intercept `get` operations, combined with **recursive closures** to manage state:\n\n- **Configuration Mode**: Accessing properties returns a new Proxy with internal closure holding accumulated `props` object\n- **Execution Mode**: When Proxy is called as function, it submits `props` and `children` to the renderer\n\n---\n\n### 🔧 TypeScript Support\n\nVanityH provides deeply optimized type inference:\n\n```typescript\nimport createVanity, { type VanityH } from \"vanity-h\";\nimport { h, VNode } from \"vue\";\n\n// Strongly typed\nconst v: VanityH\u003cVNode\u003e = createVanity(h);\n\n// Type checking\nconst element = v.div.class(\"test\").id(\"app\")(\"Content\");\n```\n\n---\n\n### 📊 Performance\n\n- **Size**: 186 bytes (minified) / ~150 bytes (gzipped)\n- **Zero Dependencies**: Pure JavaScript implementation\n- **High Performance**: Proxy interception overhead is negligible\n- **Memory Friendly**: Closure-based immutable design\n\n---\n\n### 🤝 Contributing\n\nWe welcome all forms of contributions!\n\n#### Development Setup\n\n```bash\ngit clone https://github.com/VanityH/vanityh.git\ncd vanityh\nnpm install\nnpm run dev  # Start development server\n```\n\n---\n\n### 📄 License\n\nMIT License © 2026 VanityH Team\n\n**VanityH**: Make writing render functions a pleasure, not a pain.\n\n---\n\n### 🙏 Acknowledgments\n\nThanks to these projects for inspiring VanityH:\n\n- [HTM](https://github.com/developit/htm) - JSX-like syntax in plain JavaScript\n- [DLight](https://github.com/dlight-js/dlight) - DX-first UI rendering library\n- [Hyperscript](https://github.com/hyperhype/hyperscript) - Create HTML with JavaScript\n- [SwiftUI](https://developer.apple.com/swiftui) - Declarative UI framework\n\nSpecial thanks to all developers contributing to the open source community!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanityh%2Fvanityh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvanityh%2Fvanityh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanityh%2Fvanityh/lists"}