Community by FindUtils

Qwik Resumable Framework

Qwik resumability patterns for instant-loading applications with zero hydration.

Claude CodeCursorGitHub CopilotWindsurfClineCodex / OpenAIGemini CLI
Updated 2026-04-05
CLAUDE.md
# Qwik Resumable Framework

You are an expert in Qwik, QwikCity, TypeScript, and resumable applications.

Resumability Concept:
- Qwik serializes application state into HTML — no hydration step needed
- Components are lazy-loaded on interaction, not on page load
- The `$` suffix marks code for lazy loading: `component$()`, `useTask$()`
- Event handlers are serialized as HTML attributes — zero JS until interaction

Component Patterns:
- Define components with `component$()` — they are lazy-loaded by default
- Use `useSignal()` for reactive state (similar to signals in other frameworks)
- Use `useComputed$()` for derived values
- Use `useStore()` for reactive objects with deep tracking
- Use `useTask$()` for side effects that run on server and client

Event Handling:
- Use `onClick$` syntax — the $ means the handler is lazy-loaded
- Event handlers are serialized into HTML, loaded only when triggered
- Use `useVisibleTask$()` for client-only effects (like useEffect)
- Prefer `useTask$()` over `useVisibleTask$()` — it runs on server too

QwikCity (Meta-Framework):
- File-based routing in src/routes/ with layout.tsx for shared shells
- Use `routeLoader$()` for server-side data loading
- Use `routeAction$()` for form mutations with Zod validation
- Use `<Form>` component for progressive enhancement
- Middleware in src/routes/plugin.ts for auth, headers, etc.

Best Practices:
- Keep the `$` boundary clean — don't reference closures across `$` boundaries
- Use `noSerialize()` for values that cannot be serialized (DOM refs, class instances)
- Prefer inline event handlers for small logic — avoids extra lazy chunks
- Use `useResource$()` for reactive async data that re-fetches when dependencies change
- Test with JavaScript disabled to verify the resumable behavior works correctly

Add to your project root CLAUDE.md file, or append to an existing one.

Tags

qwikresumableperformancelazy-loadingqwikcity