InstallationPermalink to “Installation”
lit-html is distributed on npm, in the lit-html package.
You can also load lit-html directly from the unpkg.com CDN:
Online editorsPermalink to “Online editors”
You can try out lit-html without installing anything using an online editor. Below are links to a simple lit-html starter project in some popular online editors:
ImportingPermalink to “Importing”
To use lit-html, import it via a path:
import statement only works inside module scripts (
<script type="module">), which can be inline scripts (as shown above) or external scripts.
The path to use depends on where you've installed lit-html. Browsers only support importing other modules by path, not by package name, so without other tools involved, you'll have to use paths.
If you use a tool that converts package names into paths, then you can import by package name:
For simplicity, the examples in these docs use package names (also known as node-style module specifiers).
See Tools for information on build tools and dev servers you can use to convert node-style module specifiers to browser-style module specifiers.
Rendering a TemplatePermalink to “Rendering a Template”
lit-html has two main APIs:
htmltemplate tag used to write templates.
render()function used to render a template to a DOM container.
To learn more about templates, see Writing Templates.