|
1 |
| -# Qwik qwik-preact ⚡️ |
| 1 | +# qwik-preact ⚡️ |
| 2 | + |
| 3 | +QwikPreact allows adding Preact components into existing Qwik application |
2 | 4 |
|
3 | 5 | ## How to Integrate into a Qwik app
|
4 | 6 |
|
5 | 7 | Integration is pretty much the same as <https://qwik.builder.io/docs/integrations/react/>.
|
6 |
| -Instead of `react` and `react-dom`, you will need to install `preact` and `preact-render-to-string`. And don't forgot `/** @jsxImportSource preact */` |
| 8 | + |
| 9 | +First, install `@qwikdev/qwik-preact` with npm, pnpm or yarn. Instead of `react` and `react-dom`, you will need to install `preact` and `preact-render-to-string`. And don't forgot `/** @jsxImportSource preact */` |
7 | 10 |
|
8 | 11 | preact.tsx
|
9 | 12 |
|
@@ -41,53 +44,25 @@ export default component$(() => {
|
41 | 44 | });
|
42 | 45 | ```
|
43 | 46 |
|
44 |
| -Please keep in mind that this is an experimental implementation based on `qwik-react` implementation. So, there might be bugs and unwanted behaviours. |
45 |
| - |
46 |
| -## Development Builds |
47 |
| - |
48 |
| -- Create a component library |
49 |
| -- Vite.js tooling. |
50 |
| -- Prettier code formatter. |
51 |
| - |
52 |
| -### Client only |
53 |
| - |
54 |
| -During development, the index.html is not a result of server-side rendering, but rather the Qwik app is built using client-side JavaScript only. This is ideal for development with Vite and its ability to reload modules quickly and on-demand. However, this mode is only for development and does not showcase "how" Qwik works since JavaScript is required to execute, and Vite imports many development modules for the app to work. |
55 |
| - |
56 |
| -``` |
57 |
| -npm run dev |
58 |
| -``` |
59 |
| - |
60 |
| -### Server-side Rendering (SSR) and Client |
61 |
| - |
62 |
| -Server-side rendered index.html, with client-side modules prefetched and loaded by the browser. This can be used to test out server-side rendered content during development, but will be slower than the client-only development builds. |
63 |
| - |
64 |
| -``` |
65 |
| -npm run dev.ssr |
66 |
| -``` |
67 |
| - |
68 |
| -## Production Builds |
69 |
| - |
70 |
| -A production build should generate the client and server modules by running both client and server build commands. |
71 |
| - |
72 |
| -``` |
73 |
| -npm run build |
74 |
| -``` |
75 |
| - |
76 |
| -### Client Modules |
77 |
| - |
78 |
| -Production build that creates only the client-side modules that are dynamically imported by the browser. |
79 |
| - |
80 |
| -``` |
81 |
| -npm run build.client |
| 47 | +vite.config.ts |
| 48 | + |
| 49 | +```ts |
| 50 | +// vite.config.ts |
| 51 | +import { qwikPreact } from '@qwikdev/qwik-preact/vite'; |
| 52 | + |
| 53 | +export default defineConfig(() => { |
| 54 | + return { |
| 55 | + ..., |
| 56 | + plugins: [ |
| 57 | + ..., |
| 58 | + // The important part |
| 59 | + qwikPreact() |
| 60 | + ], |
| 61 | + }; |
| 62 | +}); |
82 | 63 | ```
|
83 | 64 |
|
84 |
| -### Server Modules |
85 |
| - |
86 |
| -Production build that creates the server-side render (SSR) module that is used by the server to render the HTML. |
87 |
| - |
88 |
| -``` |
89 |
| -npm run build.server |
90 |
| -``` |
| 65 | +Please keep in mind that this is an experimental implementation based on `qwik-react` implementation. So, there might be bugs and unwanted behaviours. |
91 | 66 |
|
92 | 67 | ---
|
93 | 68 |
|
|
0 commit comments