qwik
Qwik is a resumable web framework that delivers instant-loading applications by eliminating hydration. It serializes application state on the server and lazily loads JavaScript on interaction, making it ideal for edge deployment.
What this skill does
# Qwik
Qwik eliminates hydration by serializing the application state into HTML. JavaScript loads lazily on user interaction, not on page load. This means near-zero JS on initial load regardless of app complexity.
## Installation
```bash
# Create Qwik project with Qwik City (meta-framework)
npm create qwik@latest
cd my-app
npm install
npm run dev
```
## Project Structure
```
# Qwik City project layout
src/
├── entry.ssr.tsx # SSR entry
├── root.tsx # Root component
├── global.css
├── routes/ # File-based routing
│ ├── layout.tsx # Root layout
│ ├── index.tsx # / page
│ └── articles/
│ ├── index.tsx # /articles
│ └── [slug]/
│ └── index.tsx # /articles/:slug
├── components/ # Reusable components
│ └── article-card/
│ └── article-card.tsx
└── lib/ # Utilities
```
## Components
```tsx
// src/components/article-card/article-card.tsx — Qwik component
import { component$ } from '@builder.io/qwik';
import { Link } from '@builder.io/qwik-city';
interface Props {
title: string;
slug: string;
excerpt: string;
}
export const ArticleCard = component$<Props>((props) => {
return (
<article>
<Link href={`/articles/${props.slug}`}>
<h2>{props.title}</h2>
</Link>
<p>{props.excerpt}</p>
</article>
);
});
```
## Signals and State
```tsx
// src/routes/counter/index.tsx — signals and reactivity
import { component$, useSignal, useComputed$, useTask$ } from '@builder.io/qwik';
export default component$(() => {
const count = useSignal(0);
const doubled = useComputed$(() => count.value * 2);
useTask$(({ track }) => {
track(() => count.value);
console.log(`Count changed to ${count.value}`);
});
return (
<div>
<p>Count: {count.value} (doubled: {doubled.value})</p>
<button onClick$={() => count.value++}>+1</button>
</div>
);
});
```
## Data Loading with routeLoader$
```tsx
// src/routes/articles/index.tsx — server-side data loading
import { component$ } from '@builder.io/qwik';
import { routeLoader$ } from '@builder.io/qwik-city';
import { ArticleCard } from '~/components/article-card/article-card';
export const useArticles = routeLoader$(async ({ env }) => {
const res = await fetch(`${env.get('API_URL')}/articles`);
return res.json() as Promise<Article[]>;
});
export default component$(() => {
const articles = useArticles();
return (
<div>
<h1>Articles</h1>
{articles.value.map((article) => (
<ArticleCard key={article.id} title={article.title} slug={article.slug} excerpt={article.excerpt} />
))}
</div>
);
});
```
## Server Actions
```tsx
// src/routes/articles/new/index.tsx — form with server action
import { component$ } from '@builder.io/qwik';
import { routeAction$, Form, zod$, z } from '@builder.io/qwik-city';
export const useCreateArticle = routeAction$(
async (data, { redirect, env }) => {
const res = await fetch(`${env.get('API_URL')}/articles`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
});
if (!res.ok) return { success: false, error: 'Failed to create' };
throw redirect(302, '/articles');
},
zod$({
title: z.string().min(1).max(200),
body: z.string().min(1),
})
);
export default component$(() => {
const action = useCreateArticle();
return (
<Form action={action}>
<input name="title" placeholder="Title" required />
<textarea name="body" placeholder="Body" required />
<button type="submit">Create</button>
{action.value?.error && <p>{action.value.error}</p>}
</Form>
);
});
```
## Layouts
```tsx
// src/routes/layout.tsx — root layout
import { component$, Slot } from '@builder.io/qwik';
import { Link } from '@builder.io/qwik-city';
export default component$(() => {
return (
<div>
<header>
<nav>
<Link href="/">Home</Link>
<Link href="/articles">Articles</Link>
</nav>
</header>
<main>
<Slot />
</main>
</div>
);
});
```
## Middleware
```tsx
// src/routes/admin/layout.tsx — auth middleware via onRequest
import { type RequestHandler } from '@builder.io/qwik-city';
export const onRequest: RequestHandler = async ({ cookie, redirect }) => {
const token = cookie.get('session')?.value;
if (!token) throw redirect(302, '/login');
};
```
## useStore for Complex State
```tsx
// src/routes/dashboard/index.tsx — store for nested reactive state
import { component$, useStore, $ } from '@builder.io/qwik';
export default component$(() => {
const state = useStore({
articles: [] as Article[],
filter: '',
loading: false,
});
const fetchArticles = $(async () => {
state.loading = true;
const res = await fetch('/api/articles');
state.articles = await res.json();
state.loading = false;
});
return (
<div>
<button onClick$={fetchArticles}>Load</button>
<input bind:value={state.filter} placeholder="Filter..." />
{state.loading ? <p>Loading...</p> : (
state.articles
.filter((a) => a.title.includes(state.filter))
.map((a) => <div key={a.id}>{a.title}</div>)
)}
</div>
);
});
```
## Deployment
```bash
# Add deployment adapter
npm run qwik add cloudflare-pages # or: vercel, netlify, node-server, deno
npm run build
npm run deploy
```
## Key Patterns
- Use `$` suffix on functions (`onClick$`, `component$`, `routeLoader$`) — it marks serialization boundaries
- Use `useSignal` for primitives, `useStore` for objects — similar to Solid's signal/store split
- `routeLoader$` runs on the server during SSR — data is serialized into HTML
- `routeAction$` handles form submissions server-side with Zod validation
- JavaScript loads lazily per interaction — no hydration step
- Use `onRequest` handlers in layouts for server-side middleware (auth, redirects)
- Deploy anywhere: Cloudflare, Vercel, Netlify, Deno, Node — via adapters
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.