Skip to content

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-js in package.json and vite-plugin-solid in the Vite config
  • createSignal, createEffect, createMemo and createResource calls
  • src/index.tsx calling render(() => <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/
createStore objects 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

  1. src/index.tsx and App.tsx
  2. Where signals and stores that matter are created
  3. createResource calls, which are where data is fetched

How a request moves through the code

  1. 1render runs App once to build the DOM.
  2. 2Components create signals and pass getter functions down as props.
  3. 3Data loads through createResource, which tracks loading and error states.
  4. 4When 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.x or splitProps on purpose.
  • Code in the component body runs once, so a console.log there won't fire again when state changes.
  • Conditional rendering usually uses <Show> and <For> rather than ternaries and .map, for performance.