by danielrhodes · 2y ago · 0 comments
In terms of building a web app where you control the environment end-to-end, I don't think there's any inherent upside to using Web Components over React.
You nailed it that we are shipping SDKs with visual components (like a video player) that need to be compatible across all kinds of frontends.
Instead of N number of SDKs to maintain where N is every front end framework, we have 2: a web component, and a React wrapper around the web component. Maybe in the (near) future we only have to maintain 1.
The upside is that web components will last longer than react components.
There was a great blog post about this very thing and why someone chose them over react components in their use case (making their code migration-proof across updates and stack changes): https://jakelazaroff.com/words/web-components-will-outlive-y...
How much are you betting? React components have been around longer and are more widely established, so personally I'd expect them to last longer.
If you're prepared to put money down on it, I'd wager $500USD on longbets that Web Components will still function in 20 years.
And I'd wager another $500USD on longbets that it will be easier to port a web component written in 2024 into a new project written in 2044 than it will be to port a react component written in 2024 into a new project written in 2044.
The reason why I'm so confident is that Web Components are already a standard.
As someone who has been doing GUI development since 16-bit Windows, it's really remarkable to me how much staying power React has. It's 10 years old and still the dominant way of building web applications. I can't think of any other frontend library (web or native) that has had that long of a run at the head of the pack.
What I'd be most concerned about with any 20-year bet is what new paradigm/library might come along and supplant the old ways. Standard or not, React has a critical mass that will keep it viable even if it becomes "legacy". If some new hotness makes web components look old-fashioned, the small community could disappear pretty fast - browser standard or no. Ask any XSLT developer.
(My reason is that I've seen standards come and go and have found e.g. old files easier to open when they're in nonstandard-but-popular-in-the-past formats than when they're in a standard format that didn't see wide adoption.)
And the WHATWG (for now) is "by invitation only"... note the big name missing.
You've already lost that bet. WebComponents v0 was not only introduced and implemented, but Google rewrote Youtube with it.
It got promptly deprecated, replaced with v1, and v0 lingered for another four years before Google rewrote Youtube with v1
Indexed for inflation?;)
What does it mean to "last longer" when it comes to your own codebase? And why would web components help with that?
...which is the point the parent comment was making.
is the crux for me. When I clone one of my Vue projects from a few years ago and try to run it, it is always broken. My (new) node version is incompatible with a Vue core library, then updating the core library breaks some other libraries and requires config file changes.
I store dependencies in-repo whenever I can get away with it; it eliminates whole classes of devops/CI issues.
Yes, I'm being hyperbolic. But if you're worried about longevity I would certainly hitch my wagon to React before I hitched it to WebComponents.
What about using web components in a server rendered application without needing to resort to running JavaScript in the server?