TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Cami.js – A no build, web component based reactive framework

113 pointsby kennyfrcover 1 year ago
Hi Everyone! My main motivation for making this was that I wanted something as powerful as Svelte or React but I wanted no build steps, no JSON API, and I wanted something as close to vanilla js as much as possible. I&#x27;m mainly a backend developer, and I wanted to simply return html with some interactive islands when I need to (whose components get &#x27;hydrated&#x27; with by backend language&#x27;s templates).<p>Some key ideas:<p>• It&#x27;s centered around light dom web components • Uses a &quot;reactive element&quot;, which uses observables for fine-grained reactivity • Rendering is done through lit-html&#x27;s tagged templates • A pub&#x2F;sub store • Easy immutability using immer (it powers the observable updates &amp; also the reducers)<p>It&#x27;s my first &#x27;serious&#x27; library that I&#x27;m using in some work prototypes, and it&#x27;s also my first &#x27;real&#x27; open source project, so comments &amp; feedback would be great!

16 comments

gitgudover 1 year ago
Nice work, love the use of reactivity via observables and pub&#x2F;sub stores (<i>some of my favourite abstractions</i>)<p>Some feedback from first glance is “type inference” could be better, which would help prevent a lot of foot-guns. Consider the example code here:<p><pre><code> this.count = this.observable(0); </code></pre> Does this allow “count” to be inferred as a “number” type in the rest of the code? There might be a way to allow JS to easily infer the types, without requiring a build step…
评论 #38148037 未加载
apsurdover 1 year ago
Looks good! FWIW I always felt the observable pattern much more intuitive than the redux&#x2F;reducer style. Something like <a href="https:&#x2F;&#x2F;mobx.js.org&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;mobx.js.org&#x2F;</a><p>Things get hairy in both, but redux pattern feels so ridiculously ceremonial all to effectively manage a huge global state object with a false sense of &quot;purity&quot;.<p>Observables otoh say &quot;fuck it, I&#x27;m mutating everything, do what you want with it&quot;.
评论 #38146249 未加载
socketclusterover 1 year ago
Great to see the interest growing around native Web Components. I&#x27;ve been working on a no-code (markup only) platform which is also based on web components.<p><a href="https:&#x2F;&#x2F;saasufy.com&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;saasufy.com&#x2F;</a><p>I built a whole chat app with authentication, blockchain and GitHub login with just 120 lines of HTML markup no front end or backend code (all the logic is abstracted away via generic, easy-to-use components provided by the platform).<p>You can also build apps which display filtered views by category or with text search with custom parameters and it does so efficiently with indexing and all updates in real time. Real time updates are delivered efficiently only to relevant components. Components automatically subscribe and unsubscribe to and from realtime changefeeds in an efficient way. Access control can be specified at the object&#x2F;model level or on individual fields.
spankaleeover 1 year ago
lit-html author here. I&#x27;m glad the template library is useful for you!<p>Question regarding interop with other web components: I don&#x27;t see how to create reactive properties on elements. Can they receive data from parents via property bindings? Ie, could a Lit element pass data to a Cami element?
评论 #38180864 未加载
评论 #38173037 未加载
infamiaover 1 year ago
Great work! This is such a great concept that slots in nicely between HTMX&#x2F;Unpoly&#x2F;AlpineJS and React&#x2F;Vue&#x2F;etc.
评论 #38148042 未加载
dxchesterover 1 year ago
Nice work! I have a no-dependencies project with somewhat similar goals in frameable&#x2F;el[0], which takes more inspiration from Vue in its interface.<p>WebComponents give us so much, but just not quite enough to be usable on their own without a little bit more on top. Reactivity with observable store and templating with event binding are the big missing pieces.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;frameable&#x2F;el">https:&#x2F;&#x2F;github.com&#x2F;frameable&#x2F;el</a>
arthropodSevenover 1 year ago
This seems like a great candidate for the few instances in my HTMX projects when it&#x27;d be a pain in the ass to write endpoints that enumerate every possible client-side state. I would love to see somebody put the two together and report on how they get along.
20after4over 1 year ago
I like it a lot! I think I will give this a try on a project I&#x27;m working on.
jslakroover 1 year ago
I see many points in common with <a href="https:&#x2F;&#x2F;www.arrow-js.com&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.arrow-js.com&#x2F;</a> Probably that focus on components could be the only difference
评论 #38147004 未加载
oknoorapover 1 year ago
I also created a webcomponent-based framework two months ago: <a href="https:&#x2F;&#x2F;realm.codes" rel="nofollow noreferrer">https:&#x2F;&#x2F;realm.codes</a>
评论 #38174655 未加载
cbrgrover 1 year ago
How does this compare with <a href="https:&#x2F;&#x2F;github.com&#x2F;preactjs&#x2F;preact">https:&#x2F;&#x2F;github.com&#x2F;preactjs&#x2F;preact</a>?
revskillover 1 year ago
Seems like Runes (Svelte 5).<p>Does this support SSR for custom component ?
评论 #38146036 未加载
评论 #38144697 未加载
mock-possumover 1 year ago
this seems pretty cool - I love me some `lit-html`. How do you feel about Cami versus straight up Lit?
评论 #38172149 未加载
评论 #38146114 未加载
评论 #38146254 未加载
pjmlpover 1 year ago
This is great, I am a big fan of vanilla.js for personal projects.<p>Thanks for sharing.
aitchnyuover 1 year ago
Umm, how do the templates escape malicious input (XSS)?
评论 #38174506 未加载
评论 #38180915 未加载
golergkaover 1 year ago
What&#x27;s the advantage of not having any build steps? For me personally, it&#x27;s an instant turn-off, as I&#x27;ll never use an untyped library.
评论 #38171824 未加载
评论 #38170947 未加载
评论 #38174146 未加载