@builder.io/sdk-react v1.0.27
Builder.io React SDK v2
This is the React v2 SDK, @builder.io/sdk-react
. It is a complete rewrite of the React SDK, and has the following benefits:
- zero client-side dependencies
- far smaller bundle size (25kb)
NOTE: if you are using the SDK in a webapp that gets deployed on a serverless environment (like Next or Hydrogen), you might need to import the SDK from @builder.io/sdk-react/edge
. This is a special import that handles edge cases surrounding serverless environments.
API Reference
To use the SDK, you need to:
fetch the builder data using
fetchOneEntry
: you can see how to use it here https://www.builder.io/c/docs/content-api, and how it differs from the React V1 SDK'sbuilder.get()
function.pass that data to the
Content
component. Here is a simplified example showing how you would use both:
import { Content, fetchOneEntry, isPreviewing } from '@builder.io/sdk-react';
import { useEffect, useState } from 'react';
const BUILDER_PUBLIC_API_KEY = 'YOUR API KEY';
function App() {
const [content, setContent] = useState(undefined);
useEffect(() => {
fetchOneEntry({
model: 'page',
apiKey: BUILDER_PUBLIC_API_KEY,
userAttributes: {
urlPath: window.location.pathname || '/',
},
}).then((content) => {
setContent(content);
});
}, []);
const shouldRenderBuilderContent = content || isPreviewing();
return shouldRenderBuilderContent ? (
<Content content={content} model="page" apiKey={BUILDER_PUBLIC_API_KEY} />
) : (
<div>Content Not Found</div>
);
}
Look at the examples for more information.
Mitosis
This SDK is generated by Mitosis. To see the Mitosis source-code, go here.
Feature Support
To check the status of the SDK, look at these tables.
Getting Started
npm install @builder.io/sdk-react
Examples
Fetch
This Package uses fetch. See these docs for more information.
8 days ago
9 days ago
10 days ago
13 days ago
16 days ago
20 days ago
21 days ago
21 days ago
21 days ago
21 days ago
22 days ago
23 days ago
24 days ago
1 month ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
9 months ago
9 months ago
9 months ago
9 months ago
6 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
7 months ago
10 months ago
8 months ago
10 months ago
7 months ago
8 months ago
10 months ago
8 months ago
11 months ago
11 months ago
11 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago