The LemonadeJS Book
LemonadeJS v6 is a micro JavaScript framework for AI agents: ~9 KB gzip, zero dependencies, zero build step, designed for the shortest verified loop from intent to working component, whether the author is a human or an AI agent.
This documentation is written as a book. Every chapter follows the same discipline: what it is, the problem it solves, how it compares to React, Vue and Angular (honestly), and real examples with measured receipts. The numbers quoted come from the test and probe suites that gate the repository; nothing here is promised that is not proven.
Part I: The Idea
- Why v6 exists: the agent-first thesis, the error-profile argument, and the receipts
- When NOT to use LemonadeJS, the honest page: SSR, ecosystem depth, compile-time optimization, and the costs of the design
- Getting started: first component in one file, no build step
Part II: The Engine
- Templates, the four rules: the entire template language fits in four rules
- State, mutable by design: assignment notifies, mutation is free; the 100,000-row receipts
- computed(), derived state, and the two bug classes it eliminates
- Events: one casing rule, real functions, CSP-safe
- Attributes: atomic attribute updates, data-* variants, why class concatenation bugs are structurally impossible
- Lists: keys, live component patching, and touch() propagation through by-reference props
- Styling covers css() values and component-owned
<style>: the single-file component story - Two-way binding: the bind directive and the bind() tool
- Refs: callback refs and useRef-style object refs, nulled on disposal
- Components and composition: by value, by name, and children
- Lifecycle and listeners: onMount, onUnmount, listen(), self-unmount
- Destroy, the chapter most frameworks don’t write: structural destruction, isDisposing(), heap-snapshot receipts
- Store: module-scope shared state without a state-management library
- Async data covers resource(): tracked fetchers, abort-previous, latest-wins
- Errors that teach: stable LJS codes and explain()
- Debugging: trace() causality as data, LJS-205 containment, inspect()
Part III: Publishing
- Contracts covers component(name, contract, fn): one declaration, every deployment
- Deployments, one block in three forms: by value, by name, custom element
- Web components: live attributes, element properties, destroy-by-default
- Using with React: adaptReact(), tested against real React 18 StrictMode
- Forms covers form() with $get/$set: states ARE the storage
- Sugar: singleton services with closed internals
- Testing and verification: the harness, verify(), and the real-browser probe discipline
Part IV: The Studio
- The Studio: 43 contract-verified blocks, the Modal primitive, and composition as architecture
- Building a block: the recipe that built the catalog, including the agent workflow
- For AI agents: contracts, llms.txt, and the verified loop