Back to Plate

Registry routes must not pull client-only trailing block helpers into the server graph

docs/solutions/developer-experience/2026-04-06-next-turbopack-needs-client-boundaries-at-react-package-entrypoints.md

53.0.53.9 KB
Original Source

Registry routes must not pull client-only trailing block helpers into the server graph

Problem

apps/www production build failed with a React Server Component error that looked like a package-entry problem:

text
You're importing a module that depends on `useEffect` into a React Server Component module.

The reported files lived under packages/core/src/react/**, which made it tempting to blame platejs/react.

That diagnosis was wrong.

Root Cause

The server-side registry route imports src/lib/rehype-utils.ts, and that file statically imports the generated registry index:

Once trailing-block-kit was added as a registry item, the generated index started exposing:

That helper imports @platejs/suggestion/react, which pulls the React editor graph into a server build path. Turbopack then reports the first hook-using files it sees in packages/core/src/react/**.

The package entrypoint was only the messenger. The real bug was that a client-only helper became part of the server-visible registry graph.

What Did Not Fix It

1. Adding 'use client' to platejs/react

That masks the bad import graph instead of removing it.

2. Moving the directive to @platejs/core/react files

That also masks the graph problem and broadens client boundaries for the wrong reason.

3. Treating the error as a generic app-page issue

The page trace was real, but the decisive server-only signal was the registry route path:

Solution

Make trailing-block-kit a real client-only kit before exposing it through the registry.

Concretely:

The problem was not that trailing-block-kit existed. The problem was that it was exposed as a server-visible registry item without declaring that it was client-only.

Why This Works

The generated registry index is read by server code. Any registry item added there must either be server-safe or mark its own client boundary.

With 'use client' on trailing-block-kit.tsx, Turbopack stops treating that helper as server-safe while keeping the kit available as registry surface.

Verification

These commands passed after converting the kit to a client-only registry item:

bash
pnpm install
pnpm --filter ./apps/www build
pnpm turbo typecheck --filter=./apps/www
pnpm lint:fix