Skip to main content

Frameworks and libraries

Best for: Modern, TypeScript-first development

import { LitElement, html, css } from 'lit';
import { customElement, property } from 'lit/decorators.js';

@customElement('lit-counter')
export class LitCounter extends LitElement {
@property({ type: Number })
count = 0;

static styles = css`
:host {
display: block;
padding: 1rem;
border: 1px solid #ddd;
}
button {
background: #007bff;
color: white;
border: none;
padding: 0.5rem 1rem;
cursor: pointer;
}
`;

render() {
return html`
<div>
<p>Count: ${this.count}</p>
<button @click=${this._increment}>Increment</button>
</div>
`;
}

private _increment() {
this.count++;
}
}

Lit provides excellent TypeScript support, a small bundle size (~5KB), and great developer experience with reactive properties and template literals with data binding. The main learning curve involves understanding TypeScript decorators.