Qwik is a web framework that delivers instant-loading apps by resuming execution on the client instead of hydrating. It ships near-zero JavaScript on initial page load.
Getting Started
npm create qwik@latest
cd my-app
npm run dev
Components with useSignal
import { component$, useSignal } from "@builder.io/qwik";
export const Counter = component$(() => {
const count = useSignal(0);
return (
<div>
<p>Count: {count.value}</p>
<button onClick$={() => count.value++}>+1</button>
</div>
);
});
useStore — Complex State
import { component$, useStore } from "@builder.io/qwik";
export const TodoApp = component$(() => {
const state = useStore({
todos: [
{ id: 1, text: "Learn Qwik", done: false },
{ id: 2, text: "Build app", done: false }
],
newTodo: ""
});
return (
<div>
<input bind:value={state.newTodo} />
<button onClick$={() => {
state.todos.push({ id: Date.now(), text: state.newTodo, done: false });
state.newTodo = "";
}}>Add</button>
{state.todos.map(todo => (
<label key={todo.id}>
<input type="checkbox" checked={todo.done}
onChange$={() => { todo.done = !todo.done; }} />
{todo.text}
</label>
))}
</div>
);
});
routeLoader$ — Server Data Loading
import { routeLoader$ } from "@builder.io/qwik-city";
export const useProducts = routeLoader$(async () => {
const res = await fetch("https://api.example.com/products");
return res.json();
});
export default component$(() => {
const products = useProducts();
return (
<ul>
{products.value.map(p => <li key={p.id}>{p.name} — ${p.price}</li>)}
</ul>
);
});
routeAction$ — Form Handling
import { routeAction$, Form } from "@builder.io/qwik-city";
export const useCreatePost = routeAction$(async (data) => {
await db.post.create({ data: { title: data.title, content: data.content } });
return { success: true };
});
export default component$(() => {
const action = useCreatePost();
return (
<Form action={action}>
<input name="title" required />
<textarea name="content" required />
<button type="submit">Create</button>
</Form>
);
});
Why Qwik?
- Resumability — no hydration, instant interactivity
- Near-zero JS on initial load
- Lazy loading of event handlers — code loads on interaction
- Built-in SSR with Qwik City
Need to extract or automate web content at scale? Check out my web scraping tools on Apify — no coding required. Or email me at spinov001@gmail.com for custom solutions.
Top comments (0)