# GoTipe in Next.js: the callback that stopped prerendering

While checking GoTipe's Next.js integration, we added an `onChange` callback to `Editor` in `app/page.tsx`. Its entire body was `console.log(editor.getJSON())`. The [updated starter guide](https://github.com/veniameen/gotipe/tree/9be5bfebb999263c2cc82aebc8eb52ffe5418bd5/examples/nextjs) now includes the wrapper used below.

Compilation passed. TypeScript passed. Prerendering `/` failed:

> Event handlers cannot be passed to Client Component props.

GoTipe supplies the block editor; the application supplies the saving logic. This check used a console callback, with no storage service involved.

## Two files, two responsibilities

The relevant files were already different kinds of component:

- `app/page.tsx` was a Server Component. That was where we had defined the callback.
- `components/editor.tsx` began with `"use client"`. Its code wires `onChange` to editor updates, passing the GoTipe editor instance.

Putting `"use client"` in the editor file does not make a function declared in its server parent serializable. Next.js documents that requirement at the [client boundary](https://nextjs.org/docs/app/api-reference/directives/use-client).

We moved the callback into a small client wrapper. Add `components/document-editor.tsx` alongside the starter's existing editor:

```tsx
"use client";

import type { Document } from "@gotipe/core";
import { Editor } from "./editor";

export function DocumentEditor({
  initialContent,
}: {
  initialContent: Document | string;
}) {
  return (
    <Editor
      initialContent={initialContent}
      onChange={(editor) => console.log(editor.getJSON())}
    />
  );
}
```

Then replace `app/page.tsx` with this caller; the server sends an HTML string and the client creates the function:

```tsx
import { DocumentEditor } from "@/components/document-editor";

export default function Home() {
  return (
    <main>
      <DocumentEditor initialContent="<p>Saved document</p>" />
    </main>
  );
}
```

The string supplies the initial document. GoTipe JSON works here too. The starter reads `initialContent` once, when creating the editor, so changing that prop later does not load another document. The [content formats](https://gotipe.com/docs/concepts/content-formats/?utm_source=hashnode&utm_medium=referral&utm_campaign=nextjs_client_callback) reference describes those inputs.

## What changed in the build

The standalone `npx --no-install tsc --noEmit` check passed. So did `npm run build`, including prerendering `/`. The failing and repaired builds both used default Turbopack and one build worker.

To reproduce, use the creation command from the starter README, install its dependencies, add these two files and run the checks. We used Node.js 24.12.0, Next.js 16.4.6, React 19.3.1, `@gotipe/core@0.1.6` and `@gotipe/block-editor@0.1.6` in an isolated consumer.

The callback still only logs JSON; a real integration replaces its body with application-owned saving, request ordering and error handling. We verified the exact snippets with types and a production build; browser callback delivery, persistence and deployment were outside this check. The successful build resolves the component-boundary error and it does not demonstrate that any edit was saved.

The starter code and core packages are MIT-licensed. GoTipe's ready-made editor UI and themes use [commercial licenses](https://gotipe.com/docs/resources/licensing/?utm_source=hashnode&utm_medium=referral&utm_campaign=nextjs_client_callback). This post was drafted with AI. The exact snippets passed TypeScript and Next.js production-build checks with the versions listed above.
