I often get asked why I use Lit to build web components. Hands down, it's become my preference after years of working with various libraries and tools

Building Custom Elements With a Library

submited by
Style Pass
2024-03-29 22:00:03

I often get asked why I use Lit to build web components. Hands down, it's become my preference after years of working with various libraries and tools. Here's why I use it.

This seems like a selfish answer for a developer to lean on, but there are advantages to end users as well. A better developer experience (DX) means I can write components and fix bugs faster. In my experience, a lot faster. Lit, for example, maps attributes to properties automatically, meaning I can omit a ton of extra logic from my code.

Abstractions like this make me more efficient at writing components because I can concentrate on the important stuff. And with less code to worry about, I find components are less prone to bugs. If I had to write those mappings myself, for example, it would get very cumbersome. More code to write, more bytes to load, and more complexity to maintain.

If I were writing vanilla web components, I'd eventually recognize patterns amidst the boilerplate. As any good developer would, I'd split them out and move them into a reusable utility of some sort. That's the DRY thing to do, right?

Leave a Comment