lit VS webcomponents

Compare lit vs webcomponents and see what are their differences.

lit

Lit is a simple library for building fast, lightweight web components. (by lit)
Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
lit webcomponents
141 34
17,535 4,312
2.1% 0.7%
9.4 4.4
6 days ago 3 months ago
TypeScript HTML
BSD 3-clause "New" or "Revised" License GNU General Public License v3.0 or later
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

lit

Posts with mentions or reviews of lit. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-04-13.
  • I've created yet another JavaScript framework
    4 projects | dev.to | 13 Apr 2024
    That is the reason why I experiment with the TiniJS framework for a while. It is a collection of tools for developing web/desktop/mobile apps using the native Web Component technology, based on the Lit library. Thank you the Lit team for creating a great tool assists us working with standard Web Component easier.
  • Web Components e a minha opiniรฃo sobre o futuro das libs front-end
    4 projects | dev.to | 4 Apr 2024
  • Show HN: I made a Pinterest clone using SigLIP image embeddings
    2 projects | news.ycombinator.com | 16 Feb 2024
    https://github.com/lit/lit/tree/main/packages/labs/virtualiz...
  • What We Need Instead of "Web Components"
    8 projects | news.ycombinator.com | 22 Dec 2023
    actually, looking at it (https://lit.dev/), i do exactly that.

    I also define a `render()` and extend my own parent, which does a `replaceChildren()` with the render. And, strangely, I also call the processor `html`

    I'll still stick with mine however, my 'framework' is half-page of code. I dislike dependencies greatly. I'd need to be saving thousand+ lines at least.

    Here, I don't want a build system to make a website; that's mad. So I don't want lit. I want the 5 lines it takes to invoke a dom parser, and the 5 lines it takes do define a webcomp parent.

  • Web Components Aren't Framework Components
    2 projects | news.ycombinator.com | 11 Dec 2023
    I rather like https://lit.dev/ for web components so far.

    For the reactivity stuff, you might want to read https://frontendmasters.com/blog/vanilla-javascript-reactivi... - it shows a bunch of no-library-required patterns that, while in a number of cases I'd much rather use a library myself, all seems at least -basically- reasonable to me and will probably be far more comprehensible to you than whatever I'd reach for, and frameworks are always much more pleasant to approach after you've already done a bunch of stuff by banging rocks together first.

  • Reddit just completed their migration out of React
    2 projects | /r/reactjs | 8 Dec 2023
  • Web Components Eliminate JavaScript Framework Lock-In
    10 projects | news.ycombinator.com | 27 Nov 2023
    I work on Lit, which I would hesitate to call a framework, but gives a framework-like DX for building web components, while trying to keep opinions to a minimum and lock-in as low as possible.

    It's got reactivity, declarative templates, great performance, SSR, TypeScript support, native CSS encapsulation, context, tasks, and more.

    It's used to build Material Design, settings and devtools UIs for Chrome, some UI for Firefox, Reddit, Photoshop Web...

    https://lit.dev if you're interested.

  • HTML Web Components
    14 projects | news.ycombinator.com | 13 Nov 2023
    I am more a fan of the augmented style because it doesn't entrap you in dev lock-in to platforms.

    The problem with frameworks, especially web frameworks, is they reimplement many items that are standard now (shadowdom, components, storage, templating, base libraries, class/async, network/realtime etc).

    If you like the component style of other frameworks but want to use Web Components, Google Lit is quite nice.

    Google Lit is like a combination of HTML Web Components and React/Vue style components. The great part is it is build on Web Components underneath.

    [1] https://lit.dev/

  • Web Components Will Outlive Your JavaScript Framework
    16 projects | news.ycombinator.com | 25 Oct 2023
    From the comments I see here, it seems like people expect the Webcomponents API to be a complete replacement for a JS framework. The thing is, our frameworks should start making use of modern web APIs, so the frameworks will have to do less themselves, so can be smaller. Lit [0] for example is doing this. Using Lit is very similar to using React. Some things work different, and you have to get used to some web component specific things, but once you get it, I think it's way more pleasant to work with than React. It feels more natural, native, less framework-specific.

    For state management, I created LitState [1], a tiny library (really only 258 lines), which integrates nicely with Lit, and which makes state management between multiple components very easy. It's much easier than the Redux/flux workflows found in React.

    So my experience with this is that it's much nicer to work with, and that the libraries are way smaller.

    [0] https://lit.dev/

  • Lit โ€“ a small responsive CSS framework
    1 project | news.ycombinator.com | 10 Oct 2023

webcomponents

Posts with mentions or reviews of webcomponents. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-11-27.
  • "open-stylable" Shadow Roots ยท Issue #909 ยท WICG/webcomponents
    1 project | news.ycombinator.com | 11 Jan 2024
  • Web Components Eliminate JavaScript Framework Lock-In
    10 projects | news.ycombinator.com | 27 Nov 2023
    It's not all that shiny. Web components have global names (you should pretty much apply a prefix/namespace if you want to work with others) and managing multiple version of the same component in the same page is an issue in any non trivial codebase (either use a different name per version or fix all breaking changes at once during the upgrade, unless the draft about scoping web elements became standard https://github.com/WICG/webcomponents/blob/gh-pages/proposal... )
  • HTML Web Components
    14 projects | news.ycombinator.com | 13 Nov 2023
    I've recently just started playing with Web Components without a build environment. Meaning, no npm, no bun, no webpack, etc, and no dependencies; in typescript. Intellij can autocompile down to js and the browser view injects a small onchange handler for live updates when developing. So far no problems.

    The only thing holding web components back seems to be HTML Modules; being able to link to a .html file instead of a .js file to import a web component. Because of this if you want to use templates or anything more complicated you need to do the ugly inject of .innerHtml = `...`, which I thought would be a problem but the IDE parses the template string very nicely. It would be great to make a component in HTML and any javascript you would put in a tag. It seems like there a lot of bureaucracy involved in getting HTML Modules out the door since its been eight years.<p><a href="https://github.com/WICG/webcomponents/blob/gh-pages/proposals/html-modules-explainer.md#high-level-summary">https://github.com/WICG/webcomponents/blob/gh-pages/proposal...</a>

  • Lit 3 Release Announcement
    9 projects | news.ycombinator.com | 10 Oct 2023
    We're trying to advocate for greater flexibility in cross-component styling. One proposal is "open styleable shadow-roots" which would be an opt-in to let styles from above a component to apply to it's shadow root. I think this would help migration in situations where app teams are currently using global stylesheets.

    Feedback and support of the need for something like this would help a lot: https://github.com/WICG/webcomponents/issues/909

  • Things you forgot because of React
    14 projects | news.ycombinator.com | 15 Aug 2023
    ))

    Part 1.

    > I honestly believe that 90% of the dislike for WC comes from the name "connectedCallback". If they'd named it "onCreate" or something, everyone would be using it

    Of course not. None of the criticism towards Web Components ever mentions "connectedCallback", or how it should be named differently.

    Do you know the actual reason so few are using them? Let's skip the atrocious not-really-high-level not-really-low-level imperative API that they offer.

    How about:

    - 13 years after introduction they still need 20 more specs to try and patch just some of the holes in their original design: https://w3c.github.io/webcomponents-cg/2022.html

    - Shadow DOM is infecting every spec so that the actual useful specs like Scoped CSS have to be delayed almost indefinitely to try and figure out how to work with this abomination of a design

    To quote the report linked above, "many of these pain points are directly related to Shadow DOM's encapsulation"

    - The amount of specs that are required to make them work, barely, and be "good web citizens". And the amount of APIs.

    Oh, you want your custom input to a) be able to send its data in a form, and b) be accessible to a label outside of your component? Well, there's a separate API for a) and there's some separate future API for b). And meanwhile your custom button won't be able to submit your form, sorry, it's a 4-year old issue with no solution: https://github.com/WICG/webcomponents/issues/814

    And all that despite the fact that there are already a dozen specs covering web components, and dozens more on their way.

    - Web Components ar HTMLElement. It means you cannot use them inside SVGs.

    This is impossible:

        
  • Building a Front End Framework; Reactivity, Composability with No Dependencies
    11 projects | news.ycombinator.com | 14 May 2023
    The lit-plugin in for VS Code offers syntax highlighting, jumpt-to-definition, etc: https://marketplace.visualstudio.com/items?itemName=runem.li...

    Prettier already supports HTML in html`` strings, likewise, CSS.

    > Is there a way in Lit to write the templates in regular HTML rather than a string?

    This would require a compiler. You would need to load the HTML into the JS module graph and JS can't do that yet, though there is a proposal for it: https://github.com/WICG/webcomponents/blob/gh-pages/proposal...

    Template in HTML also have the problem of the data not being in scope as it is in JS, and there not being an expression language. So you ned up having to re-implement a lot of JS embedded into the HTML syntax, which then preferences a compiler-based approach to make fast. It turns out to be a lot simpler to embed HTML in JS.

  • I am experimenting with Typescript. Is this way of defining a constructor considered normal or an abomination?
    2 projects | /r/webdev | 22 Feb 2023
    It's more than just sugar now. You can't even write web components functionally: https://github.com/WICG/webcomponents/issues/587
  • Declarative Shadow DOM
    5 projects | news.ycombinator.com | 13 Feb 2023
    gzip/brotli handles this very well, but it still is text to parse through.

    Some form of declarative CSS module scripts would help a lot. A feature request for that here: https://github.com/WICG/webcomponents/issues/939

  • risk of accessible components
    1 project | /r/vuejs | 17 Nov 2022
  • Templating in HTML
    5 projects | news.ycombinator.com | 4 Oct 2022
    In the past I've seen this one:

    https://github.com/WICG/webcomponents/blob/gh-pages/proposal...

    Perhaps there are more recent versions.

    I liked the spirit of the proposal, but never studied it.

What are some alternatives?

When comparing lit and webcomponents you can also consider the following projects:

Svelte - Cybernetically enhanced web apps

stencil - A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.

WHATWG HTML Standard - HTML Standard

Vue.js - This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

custom-elements - All inclusive customElements polyfill for every browser

Angular - Deliver web apps with confidence ๐Ÿš€

shoelace-css - A collection of professionally designed, every day UI components built on Web standards. SHOELACE IS BECOMING WEB AWESOME. WE ARE LIVE ON KICKSTARTER! ๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡

htmx - </> htmx - high power tools for HTML

design-reviews - W3C specs and API reviews

Preact - โš›๏ธ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.

eureka - Lucene-based search engine for your source code