Skip to content

Commit f39b3bd

Browse files
committed
feat: added another doc about open source sdk and setup steps
1 parent e428c98 commit f39b3bd

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
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.
2+
3+
##Key Features
4+
- Pure React Implementation: Built entirely with React, making it compatible with the React ecosystem
5+
- Tailwind CSS Integration: First-class support for Tailwind CSS styling
6+
- Visual Building Experience: Intuitive interface for rapid website creation
7+
- Framework Agnostic: Can be integrated into any React-based framework
8+
- Rendering API: Helper APIs to render the built pages as either HTML or React components
9+
- Extensibility: Allows extending builder via specific extension points in UI, plus the ability to create custom blocks
10+
11+
## Installation
12+
```bash
13+
pnpm add @chaibuilder/sdk
14+
```
15+
16+
## Basic Usage
17+
To implement the ChaiBuilder SDK in your React application:
18+
19+
Step 1: Add a custom tailwind config. Create a new file: tailwind.chaibuilder.config.ts.
20+
21+
Pass the path to your source files.
22+
```ts
23+
import { getChaiBuilderTailwindConfig } from "@chaibuilder/sdk/tailwind";
24+
export default getChaiBuilderTailwindConfig(["./src/**/*.{js,ts,jsx,tsx}"]);
25+
```
26+
27+
Step 2: Create a new chaibuilder.tailwind.css
28+
```css
29+
@config "./tailwind.chaibuilder.config.ts";
30+
31+
@tailwind base;
32+
@tailwind components;
33+
@tailwind utilities;
34+
```
35+
36+
Step 3: Add the builder to your page.
37+
```ts
38+
import "./chaibuilder.tailwind.css";
39+
import "@chaibuilder/sdk/styles";
40+
import {loadWebBlocks} from "@chaibuilder/sdk/web-blocks";
41+
import { ChaiBuilderEditor } from "@chaibuilder/sdk";
42+
43+
loadWebBlocks();
44+
45+
const BuilderFullPage = () => {
46+
return (
47+
<ChaiBuilderEditor
48+
blocks={[{
49+
_type: 'Heading',
50+
_id: 'a',
51+
content: 'This is a heading',
52+
styles: '#styles:,text-3xl font-bold'
53+
}]}
54+
onSave={async ({ blocks, theme } ) => {
55+
console.log(blocks, theme);
56+
return true
57+
}}
58+
/>
59+
);
60+
}
61+
```
62+
63+
## Rendering Pages
64+
One of the key features of the SDK is the ability to render built pages as both HTML and React components:
65+
```tsx
66+
import {RenderChaiBlocks} from "@chaibuilder/sdk/render";
67+
import type { ChaiType } from "@chaibuilder/sdk";
68+
69+
// Example in NextJS page.tsx
70+
export default async function Page () => {
71+
// implement your function
72+
const pageblocks: ChaiBlock[] = await getPageBlocks();
73+
return <RenderChaiBlocks blocks={pageBlocks} />
74+
}
75+
```
76+
77+
## Extending Builder
78+
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.
79+
80+
- `registerChaiBlock()`
81+
- `registerChaiMediaManager()`
82+
- `registerChaiFont()`
83+
- `registerChaiSidebarPanel()`
84+
85+
### When to Use SDK vs. Pages
86+
Use @chaibuilder/sdk when you want to build your own solution. You will need to handle everything from storage to authentication and more.
87+
Use @chaibuilder/pages when you want a complete solution where everything is handled for you.
88+
89+
> 💡 [Learn more](/docs/chaibuilder-sdk-vs-pages) about @chaibuilder/sdk vs @chaibuklder/pages
90+
91+
## Open Source
92+
The ChaiBuilder SDK is open source and available on GitHub. Contributions from the community are welcome.

0 commit comments

Comments
 (0)