Skip to content

Instantly share code, notes, and snippets.

@adamar
Created March 28, 2025 04:20
Show Gist options
  • Save adamar/9e62798b7c54a75ee8001c4f73c68fba to your computer and use it in GitHub Desktop.
Save adamar/9e62798b7c54a75ee8001c4f73c68fba to your computer and use it in GitHub Desktop.
Basic React Hello world with ESM imports
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello World React</title>
<script type="module">
import React from "https://esm.sh/[email protected]";
import ReactDOM from "https://esm.sh/[email protected]/client";
function App() {
return React.createElement("div", null, "hello world");
}
const rootElement = document.getElementById("root");
if (rootElement) {
ReactDOM.createRoot(rootElement).render(React.createElement(React.StrictMode, null, React.createElement(App)));
} else {
console.error("Root element not found.");
}
</script>
</head>
<body>
<div id="root"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment