|
| 1 | +# Builder |
| 2 | + |
| 3 | +Drag and drop page building for any website. Use your React components, publish remotely |
| 4 | + |
| 5 | +[gif with hot reload] |
| 6 | + |
| 7 | +## What is it good for? |
| 8 | + |
| 9 | +- Landing pages |
| 10 | +- Documentation |
| 11 | +- Blogging |
| 12 | +- Marketing pages (homepage, etc) |
| 13 | +- Content pages (about, FAQ, etc) |
| 14 | +- Optimization (ab test pages) |
| 15 | +- Marketing teams that never stop asking for changes |
| 16 | +- Developers who are tired of pushing pixels |
| 17 | + |
| 18 | + |
| 19 | +## Getting Started |
| 20 | + |
| 21 | +```sh |
| 22 | +npm install --save @builder.io/react |
| 23 | +``` |
| 24 | + |
| 25 | +Create a free account at [builder.io](https://builder.io) and grab your [API key](https://builder.io/account/organization) |
| 26 | + |
| 27 | +```ts |
| 28 | +import { builder, BuilderComponent } from '@builder.io/react' |
| 29 | + |
| 30 | +builder.init(YOUR_KEY) |
| 31 | +``` |
| 32 | + |
| 33 | +Then in your router |
| 34 | +```tsx |
| 35 | +<Route path="/something" render={() => <BuilderComponent model="page" />}> |
| 36 | +``` |
| 37 | + |
| 38 | +Create a new page and open your-dev-url:port/something and edit |
| 39 | + |
| 40 | +[gif] |
| 41 | + |
| 42 | +### Using your components |
| 43 | + |
| 44 | +Wrap a component |
| 45 | + |
| 46 | +```tsx |
| 47 | +import { BuilderBlock } from '@builder.io/react' |
| 48 | + |
| 49 | +@BuilderBlock({ |
| 50 | + name: 'Simple Text', |
| 51 | + inputs: [{ name: 'text', type: 'string' }] |
| 52 | +}) |
| 53 | +export class SimpleText extends React.Component { |
| 54 | + render() { |
| 55 | + return <h1>{this.props.text}</h1> |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +Then back at your page |
| 61 | + |
| 62 | +```tsx |
| 63 | +import './simple-page' |
| 64 | + |
| 65 | +// ... |
| 66 | + |
| 67 | +<Route path="/something" render={() => <BuilderComponent model="page">}> |
| 68 | +``` |
| 69 | + |
| 70 | +Open the dashboard and use it |
| 71 | + |
| 72 | +[gif] |
| 73 | + |
| 74 | +More docs on builder APIs and such at [builder.io/c/docs](https://builder.io/c/docs) |
| 75 | + |
| 76 | +For Builder decorator support you need to be using typescript or babel with legacy decorators. |
| 77 | +Alternatively you can use the alternative syntax: |
| 78 | + |
| 79 | +```tsx |
| 80 | +import { builderBlocks } from '@builder.io/react' |
| 81 | + |
| 82 | +class SimpleText extends React.Component { |
| 83 | + render() { |
| 84 | + return <h1>{this.props.text}</h1> |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +builderBlocks.add(SimpleText, { |
| 89 | + name: 'Simple Text', |
| 90 | + inputs: [{ name: 'text', type: 'string' }] |
| 91 | +}) |
| 92 | +``` |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +## Troubleshooting and feedback |
| 97 | + |
| 98 | +Problems? Requests? Open an issue. Always want feedback, interesting new use cases, happy to help. |
0 commit comments