[HN Gopher] Show HN: Cami.js - A No Build, Web Component Based R...
___________________________________________________________________
Show HN: Cami.js - A No Build, Web Component Based Reactive
Framework
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'm mainly a backend developer, and I wanted
to simply return html with some interactive islands when I need to
(whose components get 'hydrated' with by backend language's
templates). Some key ideas: * It's centered around light dom web
components * Uses a "reactive element", which uses observables for
fine-grained reactivity * Rendering is done through lit-html's
tagged templates * A pub/sub store * Easy immutability using immer
(it powers the observable updates & also the reducers) It's my
first 'serious' library that I'm using in some work prototypes, and
it's also my first 'real' open source project, so comments &
feedback would be great!
Author : kennyfrc
Score : 18 points
Date : 2023-11-04 18:33 UTC (4 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| revskill wrote:
| Seems like Runes (Svelte 5).
|
| Does this support SSR for custom component ?
| kreetx wrote:
| Not the author, but on a quick read, everything here is
| straight-up web standards so there is nothing to server-side
| render.
| kennyfrc wrote:
| Yes, Cami uses fine-grained reactivity, so it's a cousin of
| similar solutions like Solid signals, Svelte runes, Knockout /
| and MobX observables.
|
| It doesn't support SSR as it aims to be backend-agnostic (i.e.
| you can use python/ruby/haskell, and you can copy+paste the
| Cami module with no build step and you can start using it).
|
| If you want SSR for the SEO benefits, I think it's better to
| render the text-heavy parts as normal HTML for indexing with
| Google, and then mount the interactive parts with Cami / web
| components (i.e. "islands architecture":
| https://www.patterns.dev/posts/islands-architecture)
| apsurd wrote:
| Looks good! FWIW I always felt the observable pattern much more
| intuitive than the redux/reducer style. Something like
| https://mobx.js.org/
|
| 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 "purity".
|
| Observables otoh say "fuck it, I'm mutating everything, do what
| you want with it".
| mock-possum wrote:
| this seems pretty cool - I love me some `lit-html`. How do you
| feel about Cami versus straight up Lit?
| kennyfrc wrote:
| You can consider Cami as the light dom sibling of Lit (which
| uses shadow dom).
|
| Cami loses out on slots & style encapsulation, but you can
| style Cami components with normal / global css like it's part
| of the normal dom. And since there's no shadow dom overhead,
| it's more performant and there is no FOUC if you load CSS in
| <head>.
___________________________________________________________________
(page generated 2023-11-04 23:02 UTC)