Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

lit

Lit is kind of like Google's answer to React: it's a little more reliant on browser APIs like custom elements and the shadow DOM, a little less 'magic', like using JSX.

This is an example of using Lit and rendering it straight to a string, which is something that's recently popular. It works pretty well, right off the bat: Lit provides nice ESM modules and a pretty smooth workflow!

1
2
3
4
5
6
7
8
9
10
11
12
export let litExample = (async () => {
const { html } = await import("npm:lit");
const { render } = await import("npm:@lit-labs/ssr");
const { collectResult } = await import(
"npm:@lit-labs/ssr/lib/render-result.js"
);
const name = "Tom";
const page = html`<div>
Hello ${name}
</div>`;
return collectResult(render(page));
})();
June 6, 2024