Quick Start - Install and Use CNStra in 5 Minutes
Installation
Install CNStra using your preferred package manager:
# Core
npm i @cnstra/core
# Optional: React bindings
npm i @cnstra/react
# Optional: Devtools (for local debugging)
npm i -D @cnstra/devtools @cnstra/devtools-server @cnstra/devtools-transport-ws
Requirements:
- Node 18+
- TypeScript 5+ (recommended)
Minimal Example
import { CNS, collateral, neuron } from '@cnstra/core';
const userCreated = collateral<{ id: string; name: string }>('user:created');
const userRegistered = collateral<{ userId: string; status: string }>('user:registered');
const userService = neuron('user-service', { userRegistered }).dendrite({
collateral: userCreated,
response: (payload, axon) => {
console.log(`Processing user: ${payload.name}`);
return axon.userRegistered.createSignal({ userId: payload.id, status: 'completed' });
}
});
const cns = new CNS([userService]);
await cns.stimulate(userCreated.createSignal({ id: '123', name: 'John Doe' }));
Next Steps
- Understand the architecture: IERG
- Explore API: Core API
- Use in React: React Patterns
- Debugging: DevTools