Skip to content

Commit

Permalink
docs: document rsc bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Nov 11, 2023
1 parent 12cea1e commit ac59e51
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,36 @@ import { resolveAllData } from "@measured/puck";
const resolvedData = resolveAllData(data, config);
```

### React server components

If you want to use React server components, use ` <Render>` from the `@measured/puck/rsc` bundle instead of the main bundle.

```tsx
import { Render } from "@measured/puck/rsc";
import "@measured/puck/dist/index.css";

export function Page() {
return <Render config={config} data={data} />;
}
```

If you're using DropZones with React server components, use the `puck.renderDropZone` prop provided to your render function instead of the `<DropZone>` component.

```tsx
export const MyComponent: ComponentConfig = {
render: ({ puck: { renderDropZone } }) => {
return (
<div>
{renderDropZone({ zone: "first-drop-zone" })}
{renderDropZone({ zone: "second-drop-zone" })}
</div>
);
},
};
```

In future, we may deprecate DropZone in favour of renderDropZone.

## Reference

### `<Puck>`
Expand Down

0 comments on commit ac59e51

Please sign in to comment.