Skip to content

Instantly share code, notes, and snippets.

@pauleveritt
Created May 22, 2020 13:26
Show Gist options
  • Save pauleveritt/16546c0cdf1ff747824973676b2d5760 to your computer and use it in GitHub Desktop.
Save pauleveritt/16546c0cdf1ff747824973676b2d5760 to your computer and use it in GitHub Desktop.
htm preact integration for SSR VDOMs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello Bulma!</title>
<link rel="stylesheet" href="static/bulma.css">
</head>
<body>
<section class="section">
<div class="container">
<h1 class="title">
Hello World
</h1>
<p class="subtitle">
My first website with <strong>Bulma</strong>!
</p>
</div>
</section>
<script type="module">
import { html, render, h } from 'https://unpkg.com/htm/preact/standalone.module.js'
// Doesn't work
const vdom = h({
type: 'h1',
props: { id: 'hello' },
children: ['Hello world!']
})
// Works
const vdom2 = html`<a href="/">Hello!</a>`
render(vdom2, document.body);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment