Set up the visual designer

Embed the DocStudio React designer with a default template and sample data, and use the built-in View, Print and Submit actions without a server.

The designer is a React component exported from docstudio/designer. It edits a template visually and works entirely in the browser.

Install

npm install docstudio react react-dom @dnd-kit/core

Embed it

Editor.tsx
import { Designer, type DocumentPayload } from 'docstudio/designer';

export function Editor({
  template,
  data,
  save,
}: {
  template: unknown;
  data: unknown;
  save: (payload: DocumentPayload) => Promise<void>;
}): React.JSX.Element {
  return (
    <div style={{ height: '100vh' }}>
      <Designer defaultTemplate={template} sampleData={data} onSubmit={save} initialFit="page" />
    </div>
  );
}

The designer fills its parent, so give the parent a height.

Built-in actions

When you pass onSubmit, onView, onPrint or actions, the toolbar shows an action group:

Action What it does
View Opens a modal with the rendered document only. Esc closes it.
Print Opens the browser print dialog for the document only. It is never sent to a server.
Submit Calls onSubmit({ template, data }). When it resolves, the designer shows Saved.

Turn actions on or off and rename them with actions:

<Designer
  actions={{ print: false, submit: { label: 'Save report' } }}
  onSubmit={save}
  onView={show}
/>

Every callback receives { template, data }: the current template JSON and the current sample data. Nothing is added to the toolbar until you pass one of these props.

Next.js and other SSR frameworks

The designer needs a browser. In Next.js, put it in a file that starts with 'use client'. See the Next.js guide.

Learn the interface

The designer user guide explains every panel, and the feature overview shows the interface.

Last updated 2026-12-03