Last active
September 9, 2025 23:47
-
-
Save dlisboa/3c4952b1c8ef17dfbcc483fadb257696 to your computer and use it in GitHub Desktop.
React-in-HTML with JSX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- 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