Skip to content

How to understand a Qwik codebase

Qwik is built around resumability: the server renders HTML and serialises state so the browser can continue without re-running the app. The `$` suffix marks code the optimizer can split into lazily loaded chunks, which changes how you read the code: almost every handler is its own entry point.

How to tell it's Qwik

  • @builder.io/qwik or @qwik.dev/core in package.json
  • component$, useSignal, useTask$ and onClick$ throughout
  • Qwik City routes under src/routes/ with index.tsx and layout.tsx

Where things usually live

src/routes/**/index.tsx
Pages; the folder path is the URL.
src/routes/**/layout.tsx
Shared layouts and route-level loaders.
src/components/
Components declared with component$.
src/entry.ssr.tsx
Server rendering entry.
src/root.tsx
The document root.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. src/routes/ for the page you care about
  2. routeLoader$ and routeAction$ exports, which hold server-side data logic
  3. src/root.tsx for global setup

How a request moves through the code

  1. 1The server matches a route and runs its routeLoader$ functions.
  2. 2Components render to HTML with state serialised into the page.
  3. 3In the browser, nothing runs until the user interacts.
  4. 4An onClick$ handler's chunk downloads on demand and runs with the resumed state.
  5. 5Form posts call routeAction$ on the server, and loaders re-run to refresh data.

Questions to ask about the repository

  • Which data is loaded on the server for this route, and where?
  • What state is serialised into the page, and is any of it sensitive?
  • Which server functions (server$) can the browser call?

What trips people up

  • Values captured inside a $ closure must be serialisable, so some patterns that work in React fail here.
  • Debugging requires thinking in lazily loaded chunks; a handler's code may not exist in the browser until it runs.