Skip to content

Getting Started

Pulse is modular. You can install the core package alone or with framework integrations.

Terminal window
npm install @pulse-js/core @pulse-js/tools

Pulse separates state (Sources) from logic (Guards).

Sources are simple containers for values.

import { source } from "@pulse-js/core";
const name = source("World");

Guards track conditions or derived state. They automatically track dependencies.

import { guard } from "@pulse-js/core";
const message = guard(() => `Hello, ${name()}!`);

You can subscribe to changes or use the value directly.

console.log(message()); // "Hello, World!"
name.set("Pulse");
console.log(message()); // "Hello, Pulse!"

Pulse provides first-class support for major frameworks.

Terminal window
npm install @pulse-js/react

Use the usePulse hook to consume Pulse primitives in React components.

import { usePulse } from '@pulse-js/react';
import { source } from '@pulse-js/core';
const count = source(0);
function Counter() {
const value = usePulse(count);
return <button onClick={() => count.update(n => n + 1)}>{value}</button>;
}