React components
Write or generate React components for your clients' sites, with a props form for the editor, a sandboxed server render and browser code only when you ask for it.
On agency plans you can add your own React components to a client's site. Each one becomes a section the client can add from Add a section and fill in from the side panel. It is rendered to HTML on our servers in a sandbox, so visitors and search engines get real content, and it runs in visitors' browsers only if you mark it interactive.
Create a component
- In the sidebar, open Site, then Section types, and choose React components.
- Press New React component.
- Choose Describe it and say what it should do, or Write it myself and give it a name.
- Press Write the first draft or Create. The component opens in the code editor.
Write the code
- Write TSX with one default export:
export default function LoanCalculator(props) { ... }. - Import from
reactonly. Other packages aren't available. - Give every prop a default: the client may leave fields empty.
- Read
window, the time or browser storage only insideuseEffector an event handler. The first render happens on the server, where there is no browser.
To have the AI change the code, type what you want under Ask the AI to change the code and press Change it.
Describe the props
Under Props, the Schema lists the fields the client sees in the side panel. Each has a name, a label and a type: text, textarea, rich, image, link, number, toggle, select or list. Sample props fill the preview.
Choose how it runs
Under Settings:
- Runs in visitors' browsers off: visitors get the HTML it renders on the server. Use this for anything that only lays out content.
- Runs in visitors' browsers on: React starts it in the browser so it can respond to clicks and typing.
- Allowed origins: the
https://addresses it may call withfetch. The site's security policy blocks every other address.
Check it
Press Run the checks. The code is compiled, tested against the rules and rendered once on the server with the sample props, and the preview appears. Fix anything listed as Not allowed. Items marked Check are allowed but worth a second look.
Then send it for review: see Review and publish components.
What isn't allowed
The checks refuse code that runs text as code (eval, new Function), reads cookies or browser storage, opens connections other than fetch to an allowed origin, talks to other windows, changes the page's address, loads other code, or loops forever. On the server, components have no network at all and a few hundred milliseconds of CPU. A component that fails to render shows nothing on the page instead of breaking it.