{"id":16593491,"url":"https://github.com/zaceno/vite-plugin-hyperapp","last_synced_at":"2025-06-27T07:34:33.981Z","repository":{"id":249148336,"uuid":"830612276","full_name":"zaceno/vite-plugin-hyperapp","owner":"zaceno","description":"Vite-plugin to use with Hyperapp","archived":false,"fork":false,"pushed_at":"2024-07-19T19:21:30.000Z","size":23,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T16:18:24.688Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zaceno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2024-07-18T15:55:58.000Z","updated_at":"2025-01-27T09:48:41.000Z","dependencies_parsed_at":"2024-07-22T04:01:58.697Z","dependency_job_id":null,"html_url":"https://github.com/zaceno/vite-plugin-hyperapp","commit_stats":null,"previous_names":["zaceno/vite-plugin-hyperapp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zaceno/vite-plugin-hyperapp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaceno%2Fvite-plugin-hyperapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaceno%2Fvite-plugin-hyperapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaceno%2Fvite-plugin-hyperapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaceno%2Fvite-plugin-hyperapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaceno","download_url":"https://codeload.github.com/zaceno/vite-plugin-hyperapp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaceno%2Fvite-plugin-hyperapp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262212981,"owners_count":23276023,"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","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":[],"created_at":"2024-10-11T23:26:56.819Z","updated_at":"2025-06-27T07:34:33.938Z","avatar_url":"https://github.com/zaceno.png","language":"JavaScript","funding_links":[],"categories":["Utilities"],"sub_categories":[],"readme":"# vite-plugin-hyperapp\n\nUse vite as a dev-server and bundler for your hyperapp projects. Supports:\n\n- Views in JSX/TSX\n- Hot module reloading (HMR)\n- Server-side rendering (SSR)\n\n## Quickstart\n\nTo get up and running with Hyperapp and Vite in a few seconds, use [create-vite-hyperapp](https://github.com/zaceno/create-vite-hyperapp):\n\n```sh\n\u003e npm create vite-hyperapp\n```\n\nThis will set you up with all the necessary configuration described below.\n\n## Config\n\nTo manually set up your vite-project for use with Hyperapp, install this plugin:\n\n```sh\n\u003e npm install vite-plugin-hyperapp\n```\n\nAnd add it to the plugins in your `vite.config.js`:\n\n```\nimport { defineConfig } from \"vite\"\nimport hyperapp from \"vite-plugin-hyperapp\"\n\nexport default defineConfig({\n  plugins: [hyperapp()],\n})\n```\n\nYou can pass an options object to the plugin, e.g:\n\n```\n  plugins: [hyperapp({\n    optionA: 'foo',\n    optionB: 'bar',\n  })]\n```\n\n...but most of the time you won't need it. See \"Hot-module-reloading\" below for some options that might be relevant.\n\n## Typescript\n\nTo make sure you get proper typing support in your `.tsx` files, make sure to add these compiler options to your `tsconfig.json`:\n\n```\n/* Necessary for tsx to work with vite-plugin-hyperapp*/\n\"jsx\": \"preserve\",\n\"jsxImportSource\": \"vite-plugin-hyperapp\"\n```\n\n## Hot-module-reloading (HMR)\n\nFor hot-module-reloading to work, the plugin injects some code in the module where you initiate the app. It only works if the module follows these two rules:\n\n- It must contain:\n\n```js\nimport {..., app [as something],...} from 'hyperapp'\n```\n\n- It must _export_ a _named_ (not default) constant/variable `dispatch`, which should be the function retuned from calling `app({...})`.\n\nIf you'd rather name the `dispatch` export something else, you can tell the plugin the name you're using as a plugin option: `dispatchExport: \"myPreferredName\"`\n\nAnd if you'd rather use Vite's HMR api directly, or forego HMR entirely, you can use the plugin option: `hmr: false`\n\n## Server-side Rendering (SSR)\n\nGenerally, in order to set up SSR in your project you can follow Vite's instructions here: [https://vitejs.dev/guide/ssr.html#server-side-rendering](https://vitejs.dev/guide/ssr.html#server-side-rendering)\n\nHere are some specifics you'll need to know when using hyperapp and this plugin:\n\n### Redering your initial app to raw html\n\nThis plugin provides a function exported from `vite-plugin-hyperapp/ssr`, which can render your initial app as static html.\n\nFor example:\n\n```js\nimport { init, view } from \"./main\"\nimport renderApp from \"vite-plugin-hyperapp/ssr\"\nexport async function render() {\n  return await renderApp({ init, view })\n}\n```\n\n`renderApp` is an async function that takes the same options object as `hyperapp.app` - except the `node` option - and returns a promise which resolves to the html-string.\n\nNote: it is important that the server-entry module has `import ... from 'vite-plugin-hyperapp/ssr'` somewhere in it, in order for HMR to continue working on SSR enabled apps.\n\n### Mountpoint defined by the view\n\nUnlike many other framework, Hyperapp _replaces_ the given mount-node with the root node rended from the view.\n\nThis means that if your non-ssr `index.html` has this:\n\n```html\n\u003cp\u003eStatic html here\u003c/p\u003e\n\u003cdiv id=\"app\"\u003e\u003c/div\u003e\n\u003cp\u003eMore static html\u003c/p\u003e\n```\n\nand you start your app like this:\n\n```js\napp({\n  ...,\n  node: document.querySelector('#app')\n})\n```\n\nThen you _DON'T_ add your ssr outlet like this:\n\n```html\n\u003cp\u003eStatic html here\u003c/p\u003e\n\u003cdiv id=\"app\"\u003e\n  \u003c!--ssr-outlet--\u003e\n\u003c/div\u003e\n\u003cp\u003eMore static html\u003c/p\u003e\n```\n\n...but rather like this:\n\n```html\n\u003cp\u003eStatic html here\u003c/p\u003e\n\u003c!--ssr-outlet--\u003e\n\u003cp\u003eMore static html\u003c/p\u003e\n```\n\nAnd you make sure that the root-node of your view has `id=\"app\"`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaceno%2Fvite-plugin-hyperapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaceno%2Fvite-plugin-hyperapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaceno%2Fvite-plugin-hyperapp/lists"}