SolidJS
A comprehensive cheat sheet for SolidJS, the reactive JavaScript framework with fine-grained reactivity, signals, stores, and control flow components.
Components & JSX
SolidJS components are plain functions that run once. JSX compiles to real DOM operations, not a virtual DOM.
Component Basics
Components are functions that return JSX. They execute only once — reactivity handles updates.
Event Handling
Handle DOM events with on-prefixed attributes and native event delegation.
Signals
Signals are the core reactive primitive in SolidJS. They hold values and automatically track dependencies.
createSignal
Create a reactive signal that returns a getter function and a setter function.
Derived Signals
Create computed values by wrapping signal reads in a function — no special API needed.
Control Flow
SolidJS uses components for control flow instead of JavaScript expressions to maintain fine-grained reactivity.
Show & For
Conditionally render with Show and efficiently iterate lists with For.
Switch, Match & Index
Multi-condition rendering with Switch/Match and primitive-keyed iteration with Index.
Effects & Memos
Effects run side effects in response to signal changes. Memos cache derived values for performance.
createEffect
Run a side effect that automatically re-executes when its signal dependencies change.
createMemo
Create a cached derived value that only recomputes when its dependencies change.
Props Utilities
SolidJS props are reactive getters. Use mergeProps, splitProps, and children() to work with them safely.
mergeProps & splitProps
Set default props with mergeProps and separate local from pass-through props with splitProps.
children Helper
Resolve and manipulate children reactively with the children() utility.
Lifecycle
SolidJS lifecycle hooks for setup and cleanup within components.
onMount & onCleanup
Run code after the component mounts or when it unmounts.
Context
Share reactive state across the component tree without prop drilling.
createContext & useContext
Create and consume context to share state across deeply nested components.
Stores
Stores provide reactive state for nested objects and arrays with fine-grained updates.
createStore
Create a reactive store for complex nested state with path-based updates.
produce & reconcile
Use produce for mutable-style updates and reconcile for replacing store data.
Refs & DOM Access
Access and manipulate DOM elements directly using refs and directives.
Refs & Forwarding
Get direct access to DOM elements using ref and forward refs to parent components.
Resources & Data Fetching
createResource provides a reactive way to handle async data with built-in loading and error states.
createResource
Fetch async data reactively with automatic loading/error tracking and optional source signals.
Portals & Error Boundaries
Render content outside the component tree and handle errors declaratively.
Portal & ErrorBoundary
Render components into a different DOM node and catch errors in the component tree.
Reactivity Utilities
Advanced reactivity helpers for batching updates, untracking reads, and observing signals.
batch, untrack & on
Control reactivity with batching, untracking, and explicit dependency declarations.