Forma PDF

Integrate a PDF editor with React and Next.js

By WVSTECH · Reviewed November 23, 2026 · Examples target SDK 0.4.0

Forma PDF is a browser SDK. In React, mount the editor after the host element exists and destroy it on unmount. In Next.js, keep the integration in a client component and load browser-dependent code inside the effect.

A client component with lifecycle cleanup

'use client'

import { useEffect, useRef } from 'react'

export default function DocumentEditor({ layout, values }) {
  const host = useRef(null)
  useEffect(() => {
    let disposed = false
    let editor
    import('./sdk/forma-pdf.js').then(({ createEditor }) => {
      if (!disposed && host.current) {
        editor = createEditor(host.current, { layout, values, locale: 'en' })
      }
    })
    return () => { disposed = true; editor?.destroy() }
  }, [layout, values])
  return <div ref={host} style={{ height: '80vh' }} />
}

Keep document state stable

This minimal example remounts when layout or values change. In a larger application, keep stable input objects and use instance methods such as setDocument for intentional updates. Avoid feeding every onChange event back into a remount cycle.

The SDK is delivered as compiled files, rather than a public npm dependency. Adapt the import path to your bundle and include the provided stylesheet. Your server can store templates and authorize data access; the browser generates the PDF. See the SDK setup guide for package contents.

Continue building

Try the visual editor View the SDK license