Skip to content

Instantly share code, notes, and snippets.

@dlisboa
Last active September 9, 2025 23:47
Show Gist options
  • Select an option

  • Save dlisboa/3c4952b1c8ef17dfbcc483fadb257696 to your computer and use it in GitHub Desktop.

Select an option

Save dlisboa/3c4952b1c8ef17dfbcc483fadb257696 to your computer and use it in GitHub Desktop.
React-in-HTML with JSX
<!-- just serve this with Caddy and access browser -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18",
"react-dom/client": "https://esm.sh/react-dom@18/client"
}
}
</script>
<script type="module" src="https://esm.sh/tsx"></script>
</head>
<body>
<main>
<h1>Hello from HTML</h1>
</main>
<script type="text/babel">
import { createRoot } from "react-dom/client"
const root = createRoot(document.querySelector('main'))
interface Props {
name: string;
}
function App({ text = "" }: Props) {
return <h1>Hello from React! {text}</h1>
}
root.render(<App text="with TypeScript!" />)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment