Write your script in the html page. Example index.html
<head>
<meta charset="UTF-8">
<title>React + htm Demo</title>
<script src="https://unpkg.com/[email protected]" crossorigin></script>
<script src="https://unpkg.com/react@16/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" crossorigin></script>
<script type="module">
const { createElement, useState } = React;
const render = ReactDOM.render;
const html = htm.bind(createElement);
function ClickCounter() {
const [count, setCount] = useState(0);
return html`
<div>
<button onClick=${() => setCount(count + 1)}>
Clicked ${count} times
</button>
</div>
`;
}
render(html`<${ClickCounter}/>`, document.getElementById("App"));
</script>
</head>
<body>
<h1> React + htm Demo</h1>
<div id="App"/>
</body>
Source
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
https://www.w3schools.com/js/js_modules.asp
https://javascript.info/modules-intro
https://www.sitepoint.com/using-es-modules/