@sldm/core
v0.3.0
Published
Reactive primitives and core runtime for Solidum framework
Maintainers
Readme
@sldm/core
Reactive primitives and core runtime for Solidum framework
Installation
npm install @sldm/core
# or
pnpm add @sldm/coreFeatures
- ⚡ Fine-Grained Reactivity - Efficient updates with atom, computed, and effect primitives
- 🎯 Simple API - Intuitive and easy to learn
- 📦 Lightweight - Zero dependencies, small bundle size
- 🔧 Type-Safe - Fully typed with TypeScript
- 🧪 Well-Tested - Comprehensive test suite
Quick Start
import { atom, computed, effect, createElement, mount } from '@sldm/core';
// Create reactive state
const count = atom(0);
const doubled = computed(() => count() * 2);
// React to changes
effect(() => {
console.log(`Count: ${count()}, Doubled: ${doubled()}`);
});
// Update state
count(5); // Console: Count: 5, Doubled: 10
// Create UI
function Counter() {
return createElement(
'div',
{},
createElement('p', {}, `Count: ${count()}`),
createElement(
'button',
{
onClick: () => count(count() + 1),
},
'Increment'
)
);
}
// Mount to DOM
mount(document.getElementById('app'), Counter);Core APIs
Reactivity
atom(value)- Create reactive statecomputed(fn)- Derive values from atomseffect(fn)- Run side effects when atoms changebatch(fn)- Batch multiple updatesuseState(value)- Component-local state (auto-reactive)
DOM
createElement(type, props, ...children)- Create virtual nodesrender(vnode)- Render VNode to DOMmount(container, component)- Mount reactive component
Documentation
Visit https://kluth.github.io/solidum for full documentation.
License
MIT © Matthias Kluth
