The @chaibuilder/sdk
is the core foundation of the ChaiBuilder ecosystem. It is a pure React-based website builder that provides all the essential tools and components needed to create and customize websites visually using React and Tailwind CSS.
pnpm add @chaibuilder/sdk
To implement the ChaiBuilder SDK in your React application:
Step 1: Add a custom tailwind config. Create a new file: tailwind.chaibuilder.config.ts
.
Pass the path to your source files.
import { getChaiBuilderTailwindConfig } from "@chaibuilder/sdk/tailwind";
export default getChaiBuilderTailwindConfig(["./src/**/*.{js,ts,jsx,tsx}"]);
Step 2: Create a new chaibuilder.tailwind.css
@config "./tailwind.chaibuilder.config.ts";
@tailwind base;
@tailwind components;
@tailwind utilities;
Step 3: Add the builder to your page.
import "./chaibuilder.tailwind.css";
import "@chaibuilder/sdk/styles";
import {loadWebBlocks} from "@chaibuilder/sdk/web-blocks";
import { ChaiBuilderEditor } from "@chaibuilder/sdk";
loadWebBlocks();
const BuilderFullPage = () => {
return (
<ChaiBuilderEditor
blocks={[{
_type: 'Heading',
_id: 'a',
content: 'This is a heading',
styles: '#styles:,text-3xl font-bold'
}]}
onSave={async ({ blocks, theme } ) => {
console.log(blocks, theme);
return true
}}
/>
);
}
One of the key features of the SDK is the ability to render built pages as both HTML and React components:
import {RenderChaiBlocks} from "@chaibuilder/sdk/render";
import type { ChaiType } from "@chaibuilder/sdk";
// Example in NextJS page.tsx
export default async function Page () => {
// implement your function
const pageblocks: ChaiBlock[] = await getPageBlocks();
return <RenderChaiBlocks blocks={pageBlocks} />
}
The SDK allows you to extend its functionality by adding custom blocks. Also the builder allows you to add/overwrite certain functionality via our extension apis.
registerChaiBlock()
registerChaiMediaManager()
registerChaiFont()
registerChaiSidebarPanel()
The ChaiBuilder SDK is open source and available on GitHub. Contributions from the community are welcome.
Have questions or need help with Chai Builder? Our friendly community and team members are ready to assist you!
Made with Chai Builder