apajs
v1.0.2
Published
2kb library wrapping the Web Components API with reactivity out of the box.
Downloads
6
Maintainers
Readme
Apă
(water, in Romanian) – For when you just need a little hydration.
Intro
ApăJS is a minimal library aiming at reducing boilerplate around web components, yet keeping them fairly "vanilla". With its ~3kb (minified, ~1kb gzipped), it provides out-of-the-box:
- A way of creating web components with a functional approach
- Automatically add event handlers to DOM elements
- Automatically store references to the DOM to lower the boilerplate around query selectors
- First-class support for server-side rendered HTML
Getting started
The easiest way of getting started is via esm. You can import the main functions from there:
import { define, html } from "https://esm.sh/[email protected]";
define({ tag: "hello-world" }, function () {
return html`<h1>Hello world!</h1>`;
});
Alternatively, if you want to use npm, npm i apajs
.
Documentation is still WIP. If you're super curious and want to test it out, please take a look a the examples directory. There you can find several examples to have a first feel of how the syntax looks like!