Gathering detailed insights and metrics for @samijaber/lib-test
Gathering detailed insights and metrics for @samijaber/lib-test
Gathering detailed insights and metrics for @samijaber/lib-test
Gathering detailed insights and metrics for @samijaber/lib-test
npm install @samijaber/lib-test
Typescript
Module System
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
4
Use Qwik SDK to connect your Qwik application to Builder.io.
Installing the Qwik SDK is done in two steps:
This Package uses fetch. See these docs for more information.
1npm init qwik@latest
Follow instructions for setting up Qwik-city project.
Add @builder.io/sdk-qwik
to your package.json
file:
1npm add --save @builder.io/sdk-qwik
Add Qwik SDK code to a particular route (such as src/routes/index.tsx
)
1import { component$ } from "@builder.io/qwik"; 2import { loader$ } from "@builder.io/qwik-city"; 3import { 4 getBuilderSearchParams, 5 getContent, 6 RenderContent, 7} from "@builder.io/sdk-qwik"; 8 9export const BUILDER_PUBLIC_API_KEY = "YOUR_API_KEY_GOES_HERE"; // ggignore 10export const MODEL = 'page'; 11 12export const builderContentLoader = loader$(({ url }) => { 13 return getContent({ 14 model: MODEL, 15 apiKey: BUILDER_PUBLIC_API_KEY, 16 options: { 17 ...getBuilderSearchParams(url.searchParams), 18 cachebust: true, 19 }, 20 userAttributes: { 21 urlPath: url.pathname || "/", 22 }, 23 }); 24}); 25 26export default component$(() => { 27 const builderContent = builderContentLoader.use(); 28 return ( 29 <div> 30 <RenderContent 31 model={MODEL} 32 content={builderContent.value} 33 apiKey={BUILDER_PUBLIC_API_KEY} 34 // Optional: pass in a custom component registry 35 // customComponents={CUSTOM_COMPONENTS} 36 /> 37 </div> 38 ); 39}); 40 41// OPTIONAL: need to add custom components to your Qwik app 42 43export const MyFunComponent = component$((props: { text: string }) => { 44 const state = useStore({ 45 count: 0, 46 }); 47 48 return ( 49 <div> 50 <h3>{props.text.toUpperCase()}</h3> 51 <p>{state.count}</p> 52 <button onClick$={() => state.count++}>Click me</button> 53 </div> 54 ); 55}); 56 57export const CUSTOM_COMPONENTS: RegisteredComponent[] = [ 58 { 59 component: MyFunComponent, 60 name: 'MyFunComponent', 61 62 inputs: [ 63 { 64 name: 'text', 65 type: 'string', 66 defaultValue: 'Hello world', 67 }, 68 ], 69 }, 70]; 71
For using API Version v3
, you need to add apiVersion: 'v3'
to the getContent
function and in the RenderContent
tag. For example:
1import { component$ } from "@builder.io/qwik"; 2import { loader$ } from "@builder.io/qwik-city"; 3import { 4 getBuilderSearchParams, 5 getContent, 6 RenderContent, 7} from "@builder.io/sdk-qwik"; 8 9export const BUILDER_PUBLIC_API_KEY = "YOUR_API_KEY_GOES_HERE"; 10export const MODEL = "page"; 11 12export const builderContentLoader = loader$(({ url }) => { 13 return getContent({ 14 model: MODEL, 15 apiKey: BUILDER_PUBLIC_API_KEY, 16 apiVersion: "v3", 17 options: { 18 ...getBuilderSearchParams(url.searchParams), 19 cachebust: true, 20 }, 21 userAttributes: { 22 urlPath: url.pathname || "/", 23 }, 24 }); 25}); 26 27export default component$(() => { 28 const builderContent = builderContentLoader.use(); 29 return ( 30 <div> 31 <RenderContent 32 model={MODEL} 33 content={builderContent.value} 34 apiKey={BUILDER_PUBLIC_API_KEY} 35 apiVersion="v3" 36 /> 37 </div> 38 ); 39}); 40
Coming soon...
This SDK is generated by Mitosis. To see the Mitosis source-code, go here.
No vulnerabilities found.
No security vulnerabilities found.