You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libs/qwikdev-astro/README.md
+46-37Lines changed: 46 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ at the top of each Qwik component file.
76
76
77
77
This is when you may not have that many Qwik components compared to other JSX frameworks on the page.
78
78
79
-
If you face any issues, please [post them on Github](https://github.com/QwikDev/astro/issues) and attempt the manual installation below.
79
+
If you face any issues, [post them on Github](https://github.com/QwikDev/astro/issues) and attempt the manual installation below.
80
80
81
81
### Manual Installation
82
82
@@ -108,21 +108,19 @@ Now, add the integration to your `astro.config.*` file using the `integrations`
108
108
109
109
## Key differences
110
110
111
-
Hooray! We now have our integration installed. Before deep diving in, there are quite a few differences than other UI frameworks.
111
+
Before deep diving in, there are quite a few differences than other UI frameworks.
112
112
113
113
## Qwik does not hydrate, it is **fundamentally different**
114
114
115
115
Astro is popular for its partial hydration approach, whereas Qwik [does not require hydration](https://www.builder.io/blog/hydration-tree-resumability-map#resumability-is-fundamentally-a-different-algorithm).
116
116
117
-
What does this mean?
118
-
119
117
### Qwik components **do not need hydration directives**
120
118
121
119
In other UI frameworks, a hydration directive would be needed for interactivity, such as `client:only` or `client:load`. These are not needed with Qwik, because there is no hydration!
122
120
123
121
When using Qwik inside a meta framework like Astro or Qwik City, components are loaded on the server, prefetched in a separate thread, and "resumed" on the client.
124
122
125
-
For example here's how we create a counter component in Qwik (e.g. at `src/components/counter.tsx`).
123
+
For example here's how to create a counter component in Qwik (e.g. at `src/components/counter.tsx`).
126
124
127
125
```tsx
128
126
import { component$, useSignal } from "@builder.io/qwik";
It can be consumed inour`index.astro` page like so:
135
+
It can be consumed inan`index.astro` page like so:
138
136
139
137
```astro
140
138
---
@@ -157,23 +155,21 @@ It can be consumed in our `index.astro` page like so:
157
155
</html>
158
156
```
159
157
160
-
Let's take a look at this in the wild.
161
-
162
158

163
159
164
-
Here we are refreshing the page, and you'll notice nothing was executed until the button was clicked. Without resumability, our`<Counter />` would have been executed on page load.
160
+
The above example refreshes the page, and notice nothing was executed until the button was clicked. Without resumability, the`<Counter />` would have been executed on page load.
165
161
166
162
The 402 byte q-chunk is our Counter's `onClick$` handler.
167
163
168
164
#### What's in that 17.61kb chunk?
169
165
170
-
The framework!We do not execute it until it is needed. In this case it is gzipped using SSG.
166
+
The framework!It is not executed until needed. In this case it is gzipped using SSG.
171
167
172
168
## Starts fast, stays fast
173
169
174
170
One of Astro's key features is **Zero JS, by default**. Unfortunately, after adding a JavaScript framework, and any subsequent components this is usually not the case.
175
171
176
-
If we want to introduce interactivity with a framework such as React, Vue, Svelte, etc., the framework runtime is then introduced. The number of components added to the page also increases linearly O(n) with the amount of JavaScript.
172
+
When introducing interactivity with a framework such as React, Vue, Svelte, etc., the framework runtime is then introduced. The number of components added to the page also increases linearly O(n) with the amount of JavaScript.
177
173
178
174
### Astro + Qwik
179
175
@@ -187,11 +183,11 @@ Instead, upon page load, a tiny 1kb minified piece of JavaScript, known as the [
187
183
188
184
Hydration forces your hand [to eagerly execute code](https://www.builder.io/blog/hydration-sabotages-lazy-loading). It's not a problem with components that are outside of the tree, such as modals, but it must exhaustively check each component in the render tree just in case.
189
185
190
-
Qwik works exceptionally well in Astro due to Resumability and its ability to lazy load code in a fine-grained manner. Especially for marketing sites, blogs, and content oriented sites with many components.
186
+
Qwik works well in Astro due to Resumability and its ability to lazy load code in a fine-grained manner. The moment JavaScript interactivity is involved, use Qwik. Some examples include marketing sites, blogs, content oriented sites, e-commerce applications, and even full-blown web-apps at scale.
191
187
192
188
### Instant interactivity
193
189
194
-
As of `@qwikdev/astro` v0.4, we have added support for [Speculative Module Fetching](https://qwik.builder.io/docs/advanced/speculative-module-fetching/) in Astro.
190
+
As of `@qwikdev/astro` v0.4, there is support for [Speculative Module Fetching](https://qwik.builder.io/docs/advanced/speculative-module-fetching/) in Astro.
195
191
196
192
This enables instant interactivity for your Qwik components. Speculative module fetching will prefetch the application bundles in the background of a service worker, so that when needed, the code is already present in the browser cache.
197
193
@@ -203,9 +199,9 @@ While Astro generally adopts an islands architecture with other frameworks, Qwik
203
199
204
200

205
201
206
-
In the DOM, you'll notice there aren't any `<astro-island>` custom elements, this is because to Astro, Qwik looks like static data.
202
+
In the DOM, notice there aren't any `<astro-island>` custom elements, this is because to Astro, Qwik looks like static data.
207
203
208
-
> This is because in Qwik, the handlers themselves are the roots / entrypoints of the application.
204
+
>In Qwik, the handlers themselves are the roots / entrypoints of the application.
209
205
210
206
### Communicating across containers
211
207
@@ -227,7 +223,7 @@ For example, in Solid's tutorial the following is mentioned:
227
223
228
224
In Qwik, it was a design decision to not include global signal state.
229
225
230
-
Instead, we recommend the use of**custom events**, which offer several advantages:
226
+
Instead, use **custom events**, which offer several advantages:
231
227
232
228
- Performance (avoid unnecessary state synchronization)
233
229
- Does not wake up the framework on page load
@@ -236,7 +232,7 @@ Instead, we recommend the use of **custom events**, which offer several advantag
236
232
- Event Driven
237
233
- Decoupled
238
234
239
-
[This example](https://github.com/thejackshelton/astro-qwik-global-state-example/blob/main/src/components/counter.tsx) shows how custom events can be used throughout your application. Pay attention to `counter.tsx`, `random-island.tsx`, and our`index.astro` page.
235
+
[This example](https://github.com/thejackshelton/astro-qwik-global-state-example/blob/main/src/components/counter.tsx) shows how custom events can be used throughout your application. Pay attention to `counter.tsx`, `random-island.tsx`, and the `index.astro` page.
Above we're using the Qwik, React, and Solid integrations in the same Astro project.
257
+
Above the code snippet uses the Qwik, React, and Solid integrations in the same Astro project.
262
258
263
-
If we look at the first integration, it's going to look forany filein the `qwik` folder and use Qwik forany filein this folder.
259
+
The first integration in the snippet above, looks for any file in the `qwik` folder and uses Qwik for any file in this folder.
264
260
265
261
For simplicity, consider grouping common framework components in the same folder (like `/components/react/` and `/components/qwik/`). However, this is optional.
266
262
267
263
### Qwik React
268
264
269
-
If you're using React, we suggest using the `@builder.io/qwik-react` integration. It's a drop-in replacement for`@astrojs/react`, and allows a seamless transition to Qwik.
265
+
If you're using React, use the [Qwik-React integration](https://qwik.dev/docs/integrations/react/). It's a drop-in replacement for `@astrojs/react`, and allows a seamless transition to Qwik.
270
266
271
267
```tsx
272
268
import { defineConfig } from "astro/config";
@@ -283,9 +279,9 @@ export default defineConfig({
283
279
});
284
280
```
285
281
286
-
With Qwik-React, we can "qwikify" our React components, and use them in our Qwik application, even nesting Qwik and React components outside of an Astro file!
282
+
The Qwik-React integration allows you to use React components directly in Qwik.
287
283
288
-
> You do not need to specify an include property with qwikReact.
284
+
> You do not need to specify an include property with Qwik-React.
289
285
290
286
[Here's an example](https://github.com/thejackshelton/qwik-react-astro-template) of a React component with the `qwik-react` integration.
After creating our counter, it can be consumed in our [index.astro](https://github.com/thejackshelton/qwik-react-astro-template/blob/main/src/pages/index.astro) file.
303
+
After creating our counter, it can be consumed inthe [index.astro](https://github.com/thejackshelton/qwik-react-astro-template/blob/main/src/pages/index.astro) file.
308
304
309
305
```tsx
310
306
<QReactCounter qwik:visible />
311
307
```
312
308
313
-
Notice that in `.astro` files we use a `qwik:` hydration directive prefix, this is to prevent a conflict with Astro's hydration directives that are provided out of the box.
309
+
Notice that in`.astro` files there is a `qwik:` hydration directive prefix, this is to prevent a conflict with Astro's hydration directives that are provided out of the box.
314
310
315
-
You can also use the `client:*` prefix, but only in tsx files. You can find a list of directives in [Adding Interactivity](https://qwik.builder.io/docs/integrations/react/#adding-interactivity) section of the Qwik docs.
311
+
You can also use the `client:*` prefix, but only in tsx files. You can find a list of directives in the Qwik-React [Adding Interactivity](https://qwik.builder.io/docs/integrations/react/#adding-interactivity) section of the Qwik docs.
316
312
317
-
> Qwik React components still have hydration, thus it is recommended to use Qwik-React as a migration strategy to resumable components.
313
+
> Qwik React components still have hydration. It is recommended to use Qwik-React as a migration strategy to resumable components.
- [Qwik as a React alternative](https://thenewstack.io/take-a-qwik-break-from-react-with-astro/) in Astro.
378
376
379
-
## Community Guides
377
+
- [Deploy Qwik Astro with the Vercel SSR Adapter](https://dev.to/reeshee/qwik-look-at-resumability-with-astro-on-vercel-44fj).
380
378
381
-
- [Paul Scanlon](https://www.paulie.dev/) shows a hands-on look at [using Qwik in Astro over React and Vanilla JS](https://thenewstack.io/how-quiks-astro-integration-beats-both-react-and-vanilla-js/).
379
+
- [Netlify's Guide to starting a Qwik Astro project](https://developers.netlify.com/guides/adding-resumability-to-astro-with-qwik/)
382
380
383
-
- [Rishi Raj Jain](https://twitter.com/rishi_raj_jain_) has written an awesome guide on setting up Qwik with Astro's [Vercel SSR Adapter](https://dev.to/reeshee/qwik-look-at-resumability-with-astro-on-vercel-44fj).
381
+
- [Using Qwik in Astro over React and Vanilla JS](https://thenewstack.io/how-quiks-astro-integration-beats-both-react-and-vanilla-js/).
384
382
385
-
- [Paul Scanlon](https://www.paulie.dev/) explores using [Qwik as a React alternative](https://thenewstack.io/take-a-qwik-break-from-react-with-astro/) in Astro.
- Watch Jason &Steve [discuss the Qwik Astro integration](https://www.youtube.com/watch?v=W-j2HH1GdjU&t=0s) on the [LWJ show](https://www.youtube.com/@learnwithjason).
- [Awesome's Qwik + Astro video](https://www.youtube.com/watch?v=wKvkYUNBa5k) goes into how Astro just got even faster.
392
390
391
+
- Watch Jason & Steve [discuss the Qwik Astro integration](https://www.youtube.com/watch?v=W-j2HH1GdjU&t=0s) on the [LWJ show](https://www.youtube.com/@learnwithjason).
392
+
393
+
- [JLarky's insights on Qwik and potentially RSC in Astro](https://www.youtube.com/shorts/aaJuBrgQQDk)
394
+
395
+
## Talks
396
+
397
+
- [Astro and Qwik - a match made in performance heaven! - DevWorld 2024](https://www.youtube.com/watch?v=OSIjoqVK51o)
398
+
- [Astro: A New Era of Effective Lazy Loading (fr)](https://www.youtube.com/watch?v=OgRfNfCMvvQ)
399
+
393
400
## Contributing
394
401
395
-
We'd love for you to contribute! Start by reading our [Contributing Guide](https://github.com/QwikDev/astro/blob/main/contributing.md). It's got all the info you need to get involved, including an in-depth section on how the integration works under the hood.
402
+
Start by reading our [Contributing Guide](https://github.com/QwikDev/astro/blob/main/contributing.md). It includes how to get involved, and an in-depth section on how the integration works under the hood.
403
+
404
+
## Help
396
405
397
-
There's also a `qwik-astro` channel in the builder.io discord to discuss API changes, possible ideas to the integration, and other cool stuff. 😊
406
+
If you're stuck, reach out in the Astro discord or the [Qwik discord](https://discord.gg/p7E6mgXGgF), which has a dedicated [qwik-astro](https://discord.com/channels/842438759945601056/1150941080355881080) channel. Problems directly related to the integration can be created [as an issue](https://github.com/QwikDev/astro/issues).
0 commit comments