Made in Builder.io

Announcing Visual Copilot - Figma to live in half the time

Builder.io logo
Talk to Us
Platform
Developers
Talk to Us

Blog

Home

Resources

Blog

Forum

Github

Login

Signup

×

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

If you want to use the latest, second-generation Builder SDKs, understanding how the imports might have changed for your framework can help you get started smoothly so you can leverage the many improvements and updates.

Tip: Currently, the React Gen 2 SDK is in beta. We recommend that you use the Gen 1 SDK for React and React-based frameworks.

The table below outlines the features available for our SDKs.

FeatureReact (Gen1)React (Gen2)VueReact NativeSvelteQwikAngularHTML API

n/a

⚠️

⚠️

n/a

🔵

⚠️
⚠️

🔵

🔵

🔵

🔵

🔵

n/a

⚠️
⚠️

Legend

✅ Full support

🔵 Being developed

⚠️ Partial support
(hover for a tooltip with details)

❌ Not supported

Rendering your Builder content differs between Gen 1 and Gen 2.

Gen 1

In Gen 1 SDKs the component is BuilderComponent.

import { BuilderComponent } from '@builder.io/react';

<BuilderComponent model="page" content={contentJSON} />

For recommended usage and a description of the props and methods of BuilderComponent, visit Using BuilderComponent.

Gen 2

In Gen 2 SDKs the component is Content.

import { content } from '@builder.io/sdk-react';

<Content 
  model="page" 
  apiKey=YOUR_API_KEY
  content={contentJson}
 />

For recommended usage and a description of the props of the Content component, visit Using the Content Component.

Fetching data differs between Gen 1 and Gen 2.

Gen 1

In Gen 1, import builder and use the get() or getAll() helper:

import { builder } from '@builder.io/react';

const page = await builder.get('page', {
  fields: 'data.url, name',
});

const pages = await builder.getAll('page', {
  fields: 'data.url,name',
});

Gen 2

In Gen 2, import fetchOneEntry() and fetchEntries() to fetch single and multiple entries respectively. Additionally, note that the apiKey is a required field:

import { fetchOneEntry, fetchEntries } from '@builder.io/sdk-react';

const page = await fetchOneEntry({
  model: 'page',
  fields: 'data.url,name',
  apiKey: 'YOUR_API_KEY'
});

const pages = await fetchEntries({
  model: 'page',
  fields: 'data.url,name',
  apiKey: 'YOUR_API_KEY',});

For more information, visit the Content API documentation.

Registering custom components differs between Gen 1 and Gen 2.

Gen 1

In Gen 1, import the Builder object and use registerComponent():

import { Builder } from '@builder.io/react';
import { MyHero } from './MyHero';

Builder.registerComponent(MyHero, {
  name: 'Hero',
  inputs: [
   { name: 'title', type: 'string' },
  ],
});

Gen 2

In Gen 2, create a customComponents array containing all the custom components, and pass that as a prop to the Content component:

import { Content } from '@builder.io/sdk-react';
import { MyHero } from './MyHero';

// this array can contain as many custom components as you want
const customComponents = [
  {
    component: MyHero,
    name: 'Hero',
    inputs: [
      { name: 'title', type: 'string' },
    ],
  }
]

// pass the array to Content
<Content customComponents={customComponents} />

For more information on custom components, visit Registering Custom Components.

Configuring the Visual Editor differs between React Gen 1 and React Gen 2.

Gen 1

In Gen 1, import Builder and use the register() helper:

import { Builder } from '@builder.io/react';

Builder.register('insertMenu', {
  name: 'Our components',
  items: [
    { name: 'Hero' },
    { name: 'Double Columns' },
    { name: 'Triple Columns' },
    { name: 'Dynamic Columns' },
  ],
})

Gen 2

In Gen 2, import register:

import { register } from '@builder.io/sdk-react';

register('insertMenu', {
  name: 'Our components',
  items: [
    { name: 'Hero' },
    { name: 'Double Columns' }
  ],
})

The table below lists the available package names by framework and generation. Use these names for installs and imports.

FrameworkGen 1Gen 2

Qwik

n/a

@builder.io/sdk-qwik

React*

@builder.io/react

@builder.io/sdk-react

Vue**

@builder.io/vue

@builder.io/sdk-vue

The Vue Gen 2 is the recommended SDK.

Svelte

n/a

@builder.io/sdk-svelte

Solid

n/a

@builder.io/sdk-solid

React Native

n/a

@builder.io/sdk-react-native

Angular

@builder.io/angular

n/a

*Includes React-based frameworks such as Remix, Hydrogen, Gatsby, Next.js, and App Router.

**Includes Nuxt.

Tip: If you're using Remix or Hydrogen, we recommend using the Gen 2 SDK.

For fetching in advanced use cases, read Using Enrich to Fetch References and Symbols.

Was this article helpful?

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

Newsletter

Get the latest from Builder.io

By submitting, you agree to our Privacy Policy