Skip to content

Commit d823c90

Browse files
committed
feat: add Qwik example
1 parent d97ad9b commit d823c90

File tree

12 files changed

+3356
-161
lines changed

12 files changed

+3356
-161
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ package-lock.json
2626
*.iml
2727
*.lcov
2828
*.log
29+
30+
# qwik
31+
/examples/qwik/tmp
32+
/examples/qwik/server

examples/qwik/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "nitro-vite-qwik",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"scripts": {
6+
"build": "qwik build",
7+
"build.client": "vite build",
8+
"build.preview": "vite build --ssr src/entry.preview.tsx",
9+
"build.types": "tsc --incremental --noEmit",
10+
"dev": "vite --open --mode ssr",
11+
"preview": "qwik build preview && node .output/server/index.mjs",
12+
"qwik": "qwik"
13+
},
14+
"devDependencies": {
15+
"@qwik.dev/core": "^2.0.0-beta.11",
16+
"@qwik.dev/router": "^2.0.0-beta.11",
17+
"nitro": "npm:nitro-nightly",
18+
"node-fetch-native": "^1.6.7",
19+
"typescript": "5.9.3",
20+
"vite": "7.1.10",
21+
"vite-tsconfig-paths": "^5.1.4"
22+
}
23+
}

examples/qwik/public/favicon.svg

Lines changed: 1 addition & 0 deletions
Loading

examples/qwik/public/manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://json.schemastore.org/web-manifest-combined.json",
3+
"name": "qwik-project-name",
4+
"short_name": "Welcome to Qwik",
5+
"start_url": ".",
6+
"display": "standalone",
7+
"background_color": "#fff",
8+
"description": "A Qwik project app."
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
import { createQwikRouter } from "@qwik.dev/router/middleware/node";
3+
import render from "./entry.ssr";
4+
5+
export default createQwikRouter({ render });

examples/qwik/src/entry.ssr.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createRenderer } from "@qwik.dev/router";
2+
import Root from "./root";
3+
4+
export default createRenderer((opts) => {
5+
return {
6+
jsx: <Root />,
7+
options: {
8+
...opts,
9+
containerAttributes: {
10+
lang: "en-us",
11+
...opts.containerAttributes,
12+
},
13+
serverData: { ...opts.serverData },
14+
},
15+
};
16+
});

examples/qwik/src/global.css

Whitespace-only changes.

examples/qwik/src/root.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {
2+
DocumentHeadTags,
3+
RouterOutlet,
4+
useLocation,
5+
useQwikRouter,
6+
} from "@qwik.dev/router";
7+
import { component$ } from "@qwik.dev/core";
8+
9+
import "./global.css";
10+
11+
export default component$(() => {
12+
useQwikRouter();
13+
const { url } = useLocation();
14+
15+
return (
16+
<>
17+
<head>
18+
<meta charset="utf-8" />
19+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
20+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
21+
22+
<DocumentHeadTags />
23+
24+
<link rel="canonical" href={url.href} />
25+
</head>
26+
<body>
27+
<RouterOutlet />
28+
</body>
29+
</>
30+
);
31+
});

examples/qwik/src/routes/index.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { DocumentHead } from "@qwik.dev/router";
2+
import { component$, useSignal } from "@qwik.dev/core";
3+
4+
export default component$(() => {
5+
const counterSig = useSignal(0);
6+
7+
return (
8+
<div>
9+
<h1>Hello, Qwik!</h1>
10+
<button onClick$={() => (counterSig.value += 1)}>
11+
Count: {counterSig.value}
12+
</button>
13+
</div>
14+
);
15+
});
16+
17+
export const head: DocumentHead = { title: "Vite + Nitro + Qwik", meta: [] };

examples/qwik/tsconfig.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true,
4+
"target": "ES2020",
5+
"module": "ES2022",
6+
"lib": ["es2022", "DOM", "WebWorker", "DOM.Iterable"],
7+
"jsx": "react-jsx",
8+
"jsxImportSource": "@qwik.dev/core",
9+
"strict": true,
10+
"forceConsistentCasingInFileNames": true,
11+
"resolveJsonModule": true,
12+
"allowImportingTsExtensions": true,
13+
"moduleResolution": "Bundler",
14+
"esModuleInterop": true,
15+
"skipLibCheck": true,
16+
"incremental": true,
17+
"isolatedModules": true,
18+
"outDir": "tmp",
19+
"noEmit": true,
20+
"paths": {
21+
"~/*": ["./src/*"]
22+
},
23+
/* if you do not use CSS modules, remove this line and delete the typescript-plugin-css-modules module from package.json */
24+
"plugins": [{ "name": "typescript-plugin-css-modules" }]
25+
},
26+
"include": ["src", "./*.d.ts", "./*.config.ts"]
27+
}

0 commit comments

Comments
 (0)