@builder.io/sdk-qwik 0.0.6 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,70 @@
1
1
  # Builder.io SDK for Qwik
2
2
 
3
- More info coming soon.
3
+ Use Qwik SDK to connect your Qwik application to Builder.io.
4
+
5
+ ## Installation
6
+
7
+ Installing the Qwik SDK is done in two steps:
8
+
9
+ 1. Set up Qwik-city project.
10
+ 2. Install the Qwik SDK into your Qwik-city project.
11
+
12
+ ### Set up Qwik-city project
13
+
14
+ 1. Follow the instructions on [Qwik-city](https://qwik.builder.io/qwikcity/overview)
15
+
16
+ ```bash
17
+ npm init qwik@latest
18
+ ```
19
+
20
+ Follow instructions for setting up Qwik-city project.
21
+
22
+ ### Install the Qwik SDK into your Qwik-city project
23
+
24
+ Add `@builder.io/sdk-qwik` to your `package.json` file:
25
+
26
+ ```bash
27
+ npm add --save @builder.io/sdk-qwik
28
+ ```
29
+
30
+ Add Qwik SDK code to a particular route (such as `src/routes/index.tsx`)
31
+
32
+ ```typscript
33
+ import { component$, Host, Resource, useResource$ } from "@builder.io/qwik";
34
+ import { DocumentHead, useLocation } from "@builder.io/qwik-city";
35
+ import { getContent, RenderContent } from "@builder.io/sdk-qwik";
36
+
37
+ export const BUILDER_PUBLIC_API_KEY = "YOUR_API_KEY_GOES_HERE"; // ggignore
38
+ export default component$(() => {
39
+ const location = useLocation();
40
+ const builderContentRsrc = useResource$<any>(() => {
41
+ return getContent({
42
+ model: "page",
43
+ apiKey: BUILDER_PUBLIC_API_KEY,
44
+ userAttributes: {
45
+ urlPath: location.pathname || "/",
46
+ },
47
+ });
48
+ });
49
+
50
+ return (
51
+ <Host>
52
+ <Resource
53
+ resource={builderContentRsrc}
54
+ onPending={() => <div>Loading...</div>}
55
+ onResolved={(content) => (
56
+ <RenderContent
57
+ model="page"
58
+ content={content}
59
+ apiKey={BUILDER_PUBLIC_API_KEY}
60
+ />
61
+ )}
62
+ />
63
+ </Host>
64
+ );
65
+ });
66
+ ```
4
67
 
5
68
  ## Mitosis
6
69
 
7
- This SDK is generated by [Mitosis](https://github.com/BuilderIO/mitosis). To see the Mitosis source-code, go [here](../../).
70
+ This SDK is generated by [Mitosis](https://github.com/BuilderIO/mitosis). To see the Mitosis source-code, go [here](https://github.com/BuilderIO/builder/tree/main/packages/sdks/src).