Skip to content

Quick Start

Get up and running with Reaxium in minutes.


Terminal window
npm install @reaxium/core

import { atom } from '@reaxium/core';
const count = atom(0);
console.log(count.get()); // 0
count.set(1);
console.log(count.get()); // 1

const unsubscribe = count.subscribe((value) => {
console.log('Count changed:', value);
});
// Output: "Count changed: 1"
count.set(2); // Output: "Count changed: 2"
unsubscribe();

import { computed } from '@reaxium/core';
const double = computed(() => count.get() * 2, [count]);
console.log(double.get()); // 4
count.set(3);
console.log(double.get()); // 6

import { watch } from '@reaxium/core';
watch(count, (value) => {
console.log('New count:', value);
});
// Output: "New count: 3"