{"id":19621290,"url":"https://github.com/commenthol/hooked-hyper","last_synced_at":"2025-09-02T11:34:44.687Z","repository":{"id":57266548,"uuid":"420901451","full_name":"commenthol/hooked-hyper","owner":"commenthol","description":"hyperscript on hooks","archived":false,"fork":false,"pushed_at":"2021-12-30T15:55:30.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-11T22:41:13.662Z","etag":null,"topics":["hooks","hyperscript","react-like"],"latest_commit_sha":null,"homepage":"https://commenthol.github.io/hooked-hyper/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commenthol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-25T06:20:40.000Z","updated_at":"2021-12-30T15:56:48.000Z","dependencies_parsed_at":"2022-08-25T03:41:07.575Z","dependency_job_id":null,"html_url":"https://github.com/commenthol/hooked-hyper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/commenthol/hooked-hyper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fhooked-hyper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fhooked-hyper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fhooked-hyper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fhooked-hyper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commenthol","download_url":"https://codeload.github.com/commenthol/hooked-hyper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fhooked-hyper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273278819,"owners_count":25077305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"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":["hooks","hyperscript","react-like"],"created_at":"2024-11-11T11:22:15.609Z","updated_at":"2025-09-02T11:34:44.639Z","avatar_url":"https://github.com/commenthol.png","language":"JavaScript","readme":"# hooked-hyper\n\n\u003e hyperscript on hooks\n\n[Demo](https://commenthol.github.io/hooked-hyper)\n\nThis is a very simple hyperscript library to render elements directly in the DOM. So don't expect a vDOM. \n\nHooks are supported as well. \nHooks have same syntax as [React Hooks](https://reactjs.org/docs/hooks-reference.html).\n\nRe-rendering is done by (brutally) removing the affected childs. Scroll-states may get messed-up.\n\nSize is ~1kB minimized and gzipped.\n\nWill work only on modern browsers.\n\nCredits \n👏 go to [zserge/o](https://github.com/zserge/o) for inspiration.\n\n## h, render\n\nFunction `h` is used to render elements into the DOM.\n\n    h(element, props, children)\n\n`element` can be of type HTML-Node, string or functions (functional components) are accepted.\n\n```js\nrender(document.body, {}, [\n  h('span', { className: 'lorem' }, 'Lorem')\n  h('span', {}, 'ipsum')\n])\n```\n\nrenders as \n\n```html\n\u003cbody\u003e\n  \u003cspan class=\"lorem\"\u003eLorem\u003c/span\u003e\n  \u003cspan\u003eipsum\u003c/span\u003e\n\u003c/body\u003e\n```\n\nFunctional components have `children` passed as props (as with react).\n\ne.g. to render children nodes within a `\u003csection\u003e`:  \n```js\n// functional component\nfunction Comp ({ children, ...props }) {\n  return h('section', props, children)\n}\n\n// rendering\nrender(document.body, {}, [\n  h(Comp, { className: 'red' }, [\n    h('span', { className: 'lorem' }, 'Lorem')\n    h('span', {}, 'ipsum')\n  ])\n])\n```\n\nrenders as \n\n```html\n\u003cbody\u003e\n  \u003csection class=\"red\"\u003e\n    \u003cspan class=\"lorem\"\u003eLorem\u003c/span\u003e\n    \u003cspan\u003eipsum\u003c/span\u003e\n  \u003c/section\u003e\n\u003c/body\u003e\n```\n\n## usage\n\n```js\nimport { h, render } from './h.js'\n\nconst style = `\nbody \u003e .red { color: red; } \n`\n\nrender(document.body, {}, [\n  h('style', {}, style),\n  h('h1', { className: 'red' }, [\n    'hooked hyperscript'\n  ]),\n  h('p', {}, '\u003cscript\u003e/* escaping works */\u003c/script\u003e'),\n  h('p', { style: { \n    color: 'blue', \n    textTransform: 'uppercase' \n  } }, 'Lorem ipsum.'),\n  h('button', { \n    onClick: () =\u003e alert('clicked'), \n    style: { marginBottom: '1em' } \n  }, 'Click me'),\n])\n```\n\n## usage with hooks\n\n```js\nimport { render, h, Fragment, useState } from './h.js'\n\nfunction Counter (props) {\n  const style = { padding: '1em' }\n  const [count, setCount] = useState(0)\n\n  return h(Fragment, {}, [\n    h('button', { style, onClick: () =\u003e setCount(count - 1)}, '-'),\n    h('span', props, count),\n    h('button', { style, onClick: () =\u003e setCount(count + 1)}, '+'),\n  ])\n}\n\nrender(document.body, {}, \n  h(Counter, { style: { color: 'cyan' } })\n)\n```\n\nOther hooks like `useReducer`, `useEffect`, `useMemo`, `useCallback`, `useRef` and `useContext` are supported as well.\n\n# license\n\n[The Unlicense](https://unlicense.org)\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fhooked-hyper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommenthol%2Fhooked-hyper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fhooked-hyper/lists"}