Home › Qwik › Qwik + Qwik City rules

Qwik + Qwik City rules

Cursor rules for Qwik and Qwik City apps: resumability, $ boundaries, signals, routeLoader$ and routeAction$.

CursorQwik

How to use

Save this as .cursor/rules/qwik.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/qwik.mdcDownload  
---
description: Qwik + Qwik City conventions
globs: ["src/**/*.{ts,tsx}"]
alwaysApply: false
---

# Qwik / Qwik City

- Check `package.json` for the Qwik major version and follow that version's docs; APIs below are the stable core.
- Components are `component$(() => ...)`. Anything crossing a `$` boundary (event handlers, tasks, `server$`) must be serializable: no class instances, functions captured from outside, or DOM nodes in captured scope.
- State: `useSignal()` for primitives, `useStore()` for objects, `useComputed$()` for derived values. Read `.value` in JSX.
- Effects: `useTask$` (runs on server and client, track deps with `track(() => sig.value)`) and `useVisibleTask$` only when you truly need the browser on load; it defeats resumability.
- Data loading via `routeLoader$` in `routes/**/index.tsx` or `layout.tsx`; mutations via `routeAction$` + `<Form action={action}>` with `zod$` validation. Use `server$` for ad hoc server calls.
- Event handlers: `onClick$={() => ...}`; use `preventdefault:click` attributes instead of `e.preventDefault()` when possible.
- Lazy-load heavy client libraries inside the handler/task that needs them (`await import(...)`).
- Routing is file-based under `src/routes/`; layouts via `layout.tsx`; head metadata via `export const head: DocumentHead`.
- Server-only code (DB, secrets) stays in loaders/actions/`server$` or files they import; read env via `requestEvent.env.get()`.

## Don't
- Don't port React patterns (`useEffect`, `useState`) or import React libraries without `qwikify$`.

## Done when
`npm run build` (includes type check) and `npm run lint` pass.

More: all Qwik rules · all Cursor rules

Related rules

Astro content site rules

Cursor rules for Astro 5 sites with content collections, islands, and zero-JS-by-default pages.

CursorAstro

Chrome extension (Manifest V3) rules

Cursor rules for building Manifest V3 browser extensions with TypeScript and minimal permissions.

CursorChrome extensions

Lit web components rules

Cursor rules for Lit 3 web components in TypeScript: reactive properties, templates, styles, events, and accessibility.

CursorLit / web components

Next.js 16 rules (Cache Components, proxy.ts)

Cursor rules for Next.js 16 App Router: Cache Components with "use cache", proxy.ts, async request APIs, Turbopack.

CursorNext.js

Next.js App Router (TypeScript) rules

Cursor project rules for Next.js 15 App Router apps with TypeScript, Server Components, and Tailwind.

CursorNext.js

Nuxt 3 + Vue rules

Cursor rules for Nuxt 3 / Vue 3 apps using the Composition API, script setup and Pinia.

CursorVue / Nuxt

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.