@dawning-org/micro
v4.0.1
Published
ultra tiny and fast reactive framework
Maintainers
Readme
npm i @dawning-org/micro
Example
<body>
<counter-></counter->
</body>import { component, event } from "../micro.ts"
event("click");
component("counter", {
i: { count: 0 },
more(i) { i.count++ },
less(i) { i.count-- },
draw(i) {
return "<p>" + i.count + "</p><button more>+</button><button less>-</button>";
}
});366 bytes v4, 524 total (example)
SPA router only
404 is baked in by default
import { page, route } from "router.ts"
page('/', 'Home', () => `<a href="/about">About</a>`);
page('/about', 'About', () => `<a href="/">Home</a>`);
route();Minified JS: 507 bytes
Micro V4 SPA
import { component, event } from "../../micro.ts"
import { page, route } from "../../router.ts"
event("click");
component("counter", {
i: { count: 0 },
more(i) { i.count++ },
less(i) { i.count-- },
draw(i) {
return "<p>" + i.count + "</p><button more>+</button><button less>-</button>";
}
});
page('/', 'Home', () => `<h1>Home Page</h1><a href="/about">About</a><counter-></counter->`);
page('/about', 'About', () => `<a href="/">Home</a>`);
route();Minified JS: 1035 bytes
Micro SPA + Cloudflare Workers
micro-cf contains a starting template for using micro with cloudflare workers with bun bun
live example: https://micro-cf.dawnday.workers.dev/
usage:
cd micro-cf
bun i
bun run startdeploy
bun run deployV4+
- More examples
Support
Did you know this effort has gone 100% out of my pocket? If you think this project speaks for itself, consider supporting on github sponsors to continue making projects like these a reality, open & free.
Supporter or not, you can always reach me on My Discord Server, my primary communication channel Questions, feedback or support related to any of my projects, or if you need consulting.
License
Apache-2.0 license
