Skip to main content
Lit works in any environment that supports modern JavaScript modules. Choose the setup that matches your project.
Install the lit package and import it from your bundler entry point. This is the recommended setup for production applications.
npm install lit
Then import in your component file:
my-element.ts
import { LitElement, html, css } from 'lit';
import { customElement, property } from 'lit/decorators.js';

@customElement('my-element')
export class MyElement extends LitElement {
  @property()
  name = 'World';

  render() {
    return html`<p>Hello, ${this.name}!</p>`;
  }
}
The lit package re-exports everything from lit-element, lit-html, and @lit/reactive-element, so a single import covers all core APIs.

Bundler configuration

Lit ships as standard ES modules and requires no special bundler configuration. It works out of the box with Vite, Rollup, and webpack.
npm create vite@latest my-app -- --template vanilla-ts
cd my-app
npm install lit

Browser compatibility

Lit targets browsers that support: This covers all modern evergreen browsers: Chrome, Firefox, Safari, and Edge.

Polyfills for older browsers

If you need to support older browsers (e.g., legacy Edge or IE 11 is not supported), load the Web Components polyfills before your components.
npm install @webcomponents/webcomponentsjs
index.html
<!doctype html>
<html lang="en">
  <head>
    <!-- Load polyfills before any web component scripts -->
    <script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>

    <!-- Then load Lit's polyfill support module -->
    <script type="module">
      import 'lit/polyfill-support.js';
    </script>

    <script type="module" src="./my-element.js"></script>
  </head>
  <body>
    <my-element></my-element>
  </body>
</html>
The webcomponents-loader.js script detects which polyfills are needed and loads only those, minimizing the payload for browsers that already have native support.
You must also import lit/polyfill-support.js to patch Lit’s rendering pipeline to work correctly with the polyfilled custom elements and shadow DOM implementations.