@lit-core is an ahead-of-time Rust compiler and rendering toolchain for Lit and Web Components.
Web Components give teams browser-native style and DOM encapsulation, but standard builds pay for that isolation in the browser. Each component carries its own copy of shared styles, parses HTML templates at runtime, walks the DOM to wire bindings, and downloads client JavaScript before server-rendered markup can respond to user input. Sharing those components across non-Lit applications usually means maintaining wrapper layers that still ship two runtimes.
@lit-core moves that work to the build step. Developers write standard Lit components once, and the compiler optimizes styles and templates across the module graph, strips unused code, and outputs smaller Lit bundles, standalone Custom Elements, native components for other frameworks, or streaming server-rendered HTML that wakes up on interaction.
Deduplicates repeated Shadow DOM stylesheets and static markup across components into shared constructable sheets and reusable fragments. Precompiles templates, lowers decorators and directives, delegates events, and shakes unused custom element registrations so browsers ship less code and mount components with minimal main-thread work.
Streams Declarative Shadow DOM directly from Node.js and edge workers. Server-only data loaders and actions are split out of client bundles at build time, while interactive components remain dormant as pure HTML and CSS until a user interacts with them.
Compiles Lit components into standalone vanilla Custom Elements or native framework components (such as React 19) when shipping the Lit runtime is unnecessary.
Integrates directly into Vite, Rollup, and Webpack. Existing Lit codebases get whole-graph compilation, chunk-aware stylesheet sharing, and server/client asset coordination without changing component code or adding manual runtime glue.
Compiler passes and runtimes are tested against production component libraries including Carbon Web Components, Spectrum Web Components, Web Awesome, Material Web, and Cisco Momentum.
- Interactive benchmark dashboard and showcase
- Benchmark harness and results
- Browser verification suite
MIT