Installation

Get started with QuantaJS by installing the appropriate package for your needs. QuantaJS is available as two separate packages to give you exactly what you need.

Prerequisites

  • Node.js (v14 or higher)
  • npm (v6 or higher), yarn, or pnpm

Package Options

@quantajs/core

For framework-agnostic state management in any JavaScript environment.

npm install @quantajs/core
# or
yarn add @quantajs/core
# or
pnpm add @quantajs/core

@quantajs/react

For React applications with built-in hooks and components.

npm install @quantajs/react @quantajs/core
# or
yarn add @quantajs/react @quantajs/core
# or
pnpm add @quantajs/react @quantajs/core

@quantajs/react depends on @quantajs/core, so both packages will be installed when you install the React package.

Usage Examples

Core Package

import { createStore, reactive, computed, watch } from '@quantajs/core';

// Create a store
const counter = createStore('counter', {
  state: () => ({ count: 0 }),
  actions: { increment() { this.count++; } },
});

React Package

import { createStore, QuantaProvider, useStore } from '@quantajs/react';

// Create a store
const counterStore = createStore('counter', {
  state: () => ({ count: 0 }),
  actions: { increment() { this.count++; } },
});

// Use in React components
function Counter() {
  const store = useStore();
  return (
    <div>
      <p>Count: {store.count}</p>
      <button onClick={() => store.increment()}>Increment</button>
    </div>
  );
}

Next Steps