Rendering On Demand
Lexical in Payload is a React Server Component (RSC). Historically that created three headaches: 1. You couldn't render the editor directly from the client. 2. Features like blocks, tables and link drawers require the server to know the shape of nested sub-fields at render time. If you tried to render on demand, the server didn't know those schemas. 3. The rich text field is designed to live inside a Form. For simple use cases, setting up a full form just to manage editor state was cumbersome.
To simplify rendering richtext on demand, <RenderLexical />, that renders a Lexical editor while still covering the full feature set. On mount, it calls a server action to render the editor on the server using the new render-field server function. That server render gives Lexical everything it needs (including nested field schemas) and returns a ready-to-hydrate editor.
Inside an existing Form
If you have an existing Form and want to render a richtext field within it, you can use the RenderLexical component like this:
Outside of a Form (you control state)
Choosing the schemaPath
schemaPath tells the server which richText field to render. This gives the server the exact nested field schemas (blocks, relationship drawers, upload fields, tables, etc.).
Format:
collection.<collectionSlug>.<fieldPath>global.<globalSlug>.<fieldPath>
Example (top level): collection.posts.richText
Example (nested in a group/tab): collection.posts.content.richText
Was this page helpful?