How to understand a SolidJS codebase
SolidJS uses JSX that looks like React, but components run only once. Reactivity comes from signals created with `createSignal`, and only the exact DOM nodes that read a signal update. Reading Solid code means following signals, not re-renders.
How to tell it's SolidJS
solid-jsinpackage.jsonandvite-plugin-solidin the Vite configcreateSignal,createEffect,createMemoandcreateResourcecallssrc/index.tsxcallingrender(() => <App />, root)
Where things usually live
- src/index.tsx
- Renders the app into the DOM.
- src/App.tsx
- Root component, often defining routes with
@solidjs/router. - src/components/
- Components: functions that set up reactive bindings once.
- src/stores/
createStoreobjects for nested shared state.- src/routes/
- Route components; in SolidStart, file-based routes.
Conventions, not rules. Real projects rename and move things, so confirm against the repository.
Where to start reading
src/index.tsxandApp.tsx- Where signals and stores that matter are created
createResourcecalls, which are where data is fetched
How a request moves through the code
renderrunsApponce to build the DOM.- Components create signals and pass getter functions down as props.
- Data loads through
createResource, which tracks loading and error states. - When a signal changes, only the expressions that read it update the DOM; the component function does not run again.
Questions to ask about the repository
- Which signals hold the app's important state, and who writes to them?
- Where are resources fetched, and what triggers a refetch?
- Are any props being destructured in a way that breaks reactivity?
What trips people up
- Destructuring props breaks reactivity; Solid code uses
props.xorsplitPropson purpose. - Code in the component body runs once, so a
console.logthere won't fire again when state changes. - Conditional rendering usually uses
<Show>and<For>rather than ternaries and.map, for performance.