{"id":19382926,"url":"https://github.com/kenoxa/svelte-htm","last_synced_at":"2025-08-09T02:24:38.944Z","repository":{"id":37960314,"uuid":"274399326","full_name":"kenoxa/svelte-htm","owner":"kenoxa","description":"tagged template syntax for svelte to simplify testing","archived":false,"fork":false,"pushed_at":"2023-12-19T00:07:04.000Z","size":1381,"stargazers_count":27,"open_issues_count":13,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-15T01:21:13.482Z","etag":null,"topics":["hyperscript","js","jsx","svelte","tagged-template-literals","testing"],"latest_commit_sha":null,"homepage":"","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/kenoxa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2020-06-23T12:25:34.000Z","updated_at":"2025-05-20T12:12:30.000Z","dependencies_parsed_at":"2024-06-18T16:58:38.815Z","dependency_job_id":"a8b781b8-e661-405c-a601-470247f68a95","html_url":"https://github.com/kenoxa/svelte-htm","commit_stats":{"total_commits":39,"total_committers":5,"mean_commits":7.8,"dds":0.5897435897435898,"last_synced_commit":"ab69b4e15fdf26bcf7d9fbbb30faec44d3c8c4d7"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/kenoxa/svelte-htm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenoxa%2Fsvelte-htm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenoxa%2Fsvelte-htm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenoxa%2Fsvelte-htm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenoxa%2Fsvelte-htm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kenoxa","download_url":"https://codeload.github.com/kenoxa/svelte-htm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenoxa%2Fsvelte-htm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269519188,"owners_count":24430822,"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-08-09T02:00:10.424Z","response_time":111,"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":["hyperscript","js","jsx","svelte","tagged-template-literals","testing"],"created_at":"2024-11-10T09:23:52.791Z","updated_at":"2025-08-09T02:24:38.850Z","avatar_url":"https://github.com/kenoxa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svelte-htm\n\n\u003e [**H**yperscript **T**agged **M**arkup](https://www.npmjs.com/package/htm) for [svelte](https://svelte.dev/) to simplify testing\n\n[![License](https://badgen.net/npm/license/svelte-htm)](https://github.com/kenoxa/svelte-htm/blob/main/LICENSE)\n[![Latest Release](https://badgen.net/npm/v/svelte-htm)](https://www.npmjs.com/package/svelte-htm)\n[![View changelog](https://badgen.net/badge/%E2%80%8B/Explore%20Changelog/green?icon=awesome)](https://changelogs.xyz/svelte-htm)\n\n[![CI](https://github.com/kenoxa/svelte-htm/workflows/CI/badge.svg)](https://github.com/kenoxa/svelte-htm/actions?query=branch%3Amain+workflow%3ACI)\n[![Coverage Status](https://badgen.net/coveralls/c/github/kenoxa/svelte-htm/main)](https://coveralls.io/github/kenoxa/svelte-htm?branch=main)\n[![PRs Welcome](https://badgen.net/badge/PRs/welcome/purple)](http://makeapullrequest.com)\n[![Conventional Commits](https://badgen.net/badge/Conventional%20Commits/1.0.0/cyan)](https://conventionalcommits.org)\n\n\u003e If your are already using [babel](https://babeljs.io/) take a look at [svelte-jsx].\n\n## What?\n\nWrite svelte components in [jsx]-like [syntax](https://www.npmjs.com/package/htm#syntax-like-jsx-but-also-lit) in Standard JavaScript [Tagged Templates] which works in [all modern browsers] and in node.\n\n## Why?\n\nThis is especially useful for [testing svelte components](https://github.com/svelte-society/recipes-mvp/blob/master/testing.md).\n\n## Installation\n\n```sh\nnpm install --save-dev svelte-htm\n```\n\nAnd then import it:\n\n```js\n// using es modules\nimport html from 'svelte-htm'\n\n// common.js\nconst html = require('svelte-htm')\n```\n\nAlternatively use [UNPKG](https://unpkg.com/svelte-htm/) or [jsDelivr](https://cdn.jsdelivr.net/npm/svelte-htm/) packages:\n\nWith script tags and globals:\n\n```html\n\u003c!-- UNPKG --\u003e\n\u003cscript src=\"https://unpkg.com/svelte-htm\"\u003e\u003c/script\u003e\n\n\u003c!-- jsDelivr --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/svelte-htm\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n  \u003c!-- And then grab it off the global like so: --\u003e\n  const html = svelteHtml\n\u003c/script\u003e\n```\n\nHotlinking from unpkg: _(no build tool needed!)_\n\n```js\nimport html from 'https://unpkg.com/svelte-htm?module'\n```\n\n## Usage\n\n```js\nimport { render, fireEvent } from '@testing-library/svelte'\nimport html from 'svelte-htm'\n\nimport Button from '../src/Button.svelte'\n\ntest('should render', async () =\u003e {\n  let clicked = 0\n  const { getByRole } = render(html`\u003c${Button} on:click=${() =\u003e (clicked += 1)}\u003eClick Me!\u003c//\u003e`)\n\n  const button = getByRole('button')\n\n  await fireEvent.click(button)\n\n  expect(clicked).toBe(1)\n})\n```\n\n## API\n\nWe [aim to support](https://github.com/kenoxa/svelte-hyperscript#feature-set) all svelte features. In some cases this is not possible. For those cases we provided feasible workarounds. See [svelte-hyperscript] for further details.\n\nSome notable differences are:\n\n- Using [stores](https://svelte.dev/docs#svelte_store) to allow reactivity\n\n  ```js\n  import { render } from '@testing-library/svelte'\n  import userEvent from '@testing-library/user-event'\n  import { writable, get } from 'svelte/store'\n\n  test('write into an input', async () =\u003e {\n    const text = writable()\n    const { getByRole } = render(html`\u003cinput bind:value=${text} /\u003e`)\n\n    const input = getByRole('textbox')\n\n    await userEvent.type(input, 'some text')\n\n    expect(get(text)).toBe('some text')\n  })\n  ```\n\n- Action properties lack the possibility to pass parameters to the action\n\n  ```js\n  import action from 'some-action-module'\n\n  html`\u003cdiv use:action=${(node) =\u003e action(node, parameters)}\u003e\u003c/div\u003e`\n  ```\n\n## Related Projects\n\n- [svelte-jsx] - write svelte components using [jsx]\n- [svelte-hyperscript] - the core of this implementation\n- [svelte-fragment-component] - a utility component\n- [htm](https://www.npmjs.com/package/htm) - making **H**yperscript **T**agged **M**arkup possible\n- [@testing-library/svelte](https://testing-library.com/docs/svelte-testing-library/intro) - helps to test UI components in a user-centric way\n\n## Support\n\nThis project is free and open-source, so if you think this project can help you or anyone else, you may [star it on GitHub](https://github.com/kenoxa/svelte-htm). Feel free to [open an issue](https://github.com/kenoxa/svelte-htm/issues) if you have any idea, question, or you've found a bug.\n\n## Contribute\n\nThanks for being willing to contribute!\n\n**Working on your first Pull Request?** You can learn how from this _free_ series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)\n\nWe are following the [Conventional Commits](https://www.conventionalcommits.org) convention.\n\n### Develop\n\n- `npm test`: Run test suite\n- `npm run build`: Generate bundles\n- `npm run lint`: Lints code\n\n## NPM Statistics\n\n[![NPM](https://nodei.co/npm/svelte-htm.png)](https://nodei.co/npm/svelte-htm/)\n\n## License\n\n`svelte-htm` is open source software [licensed as MIT](https://github.com/kenoxa/svelte-htm/blob/main/LICENSE).\n\n[tagged templates]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates\n[all modern browsers]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Browser_compatibility\n[jsx]: https://reactjs.org/docs/introducing-jsx.html\n[svelte-jsx]: https://www.npmjs.com/package/svelte-jsx\n[svelte-hyperscript]: https://www.npmjs.com/package/svelte-hyperscript\n[svelte-fragment-component]: https://www.npmjs.com/package/svelte-fragment-component\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenoxa%2Fsvelte-htm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenoxa%2Fsvelte-htm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenoxa%2Fsvelte-htm/lists"}