Get Started
Quick Start
Build and understand a small, real component in under ten minutes.
A todo list
We’ll build a todo list with add, toggle, and a live remaining-count — enough surface area to see signals, derived values, and lists working together.
1. Define the state
A list of todos lives in one signal. Each todo is a plain object; Pulse doesn’t require any special wrapper for values inside a collection.
import { signal, computed } from "pulse";
type Todo = { id: number; text: string; done: boolean };
const todos = signal<Todo[]>([]);
const remaining = computed(() => todos().filter((t) => !t.done).length);2. Add items
Mutating state in Pulse always goes through .set() — pass a new array rather than pushing into the old one, so Pulse can compare references cheaply.
function addTodo(text: string) {
todos.set([...todos(), { id: Date.now(), text, done: false }]);
}3. Render the list
export function TodoList() {
const draft = signal("");
return (
<div>
<input
value={draft()}
onInput={(e) => draft.set(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter" && draft().trim()) {
addTodo(draft());
draft.set("");
}
}}
/>
<ul>
{todos().map((todo) => (
<li key={todo.id}>
<label>
<input
type="checkbox"
checked={todo.done}
onChange={() => toggle(todo.id)}
/>
{todo.text}
</label>
</li>
))}
</ul>
<p>{remaining()} items left</p>
</div>
);
}Why computed()
remaining recalculates only when todos actually changes, and only the text node that renders it updates in the DOM — the list itself is untouched.
What’s next
You’ve now used the three primitives that make up most Pulse apps: signal, computed, and JSX that reads them directly. Head to Core Concepts to see how they compose in larger applications.