What’s broken?
When using BlockNote AI with Next.js or any Node.js backend, importing from '@blocknote/xl-ai/server' fails with an error like:
Error: Attempted to call injectDocumentStateMessages() from the server but injectDocumentStateMessages is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.
This is due to the top of 'packages/xl-ai/src/server.ts' containing a '"use client";' directive. As a result, the built server bundle ('dist/server.js') is treated as client-only by frameworks like Next.js, even though it's intended for server use only.
What did you expect to happen?
Importing from '@blocknote/xl-ai/server' in server-side code (API routes, Node.js backends, etc) should work fine and export functions usable on the server, such as injectDocumentStateMessages. There should be no 'use client' directive in the server entry file or any part of the server bundle.
Steps to reproduce
- Import '@blocknote/xl-ai/server' in a Next.js API route or Node.js script
- Attempt to use any utility (e.g. injectDocumentStateMessages)
- Observe error: Attempted to call injectDocumentStateMessages() from the server but ... is on the client.
BlockNote version
0.51.4 (latest as of 2026-06-06)
Environment
Node.js 20; Next.js 14.x; Linux and macOS; tested both in local and Vercel/production
Additional context
Root cause:
Suggested fix:
- Remove the '"use client";' line from packages/xl-ai/src/server.ts (and rebuild). This will allow the export to work correctly for server-side consumers.
See discussion above for analysis, and user-provided stacktraces.
Contribution
Sponsor
What’s broken?
When using BlockNote AI with Next.js or any Node.js backend, importing from '@blocknote/xl-ai/server' fails with an error like:
This is due to the top of 'packages/xl-ai/src/server.ts' containing a '"use client";' directive. As a result, the built server bundle ('dist/server.js') is treated as client-only by frameworks like Next.js, even though it's intended for server use only.
What did you expect to happen?
Importing from '@blocknote/xl-ai/server' in server-side code (API routes, Node.js backends, etc) should work fine and export functions usable on the server, such as injectDocumentStateMessages. There should be no 'use client' directive in the server entry file or any part of the server bundle.
Steps to reproduce
BlockNote version
0.51.4 (latest as of 2026-06-06)
Environment
Node.js 20; Next.js 14.x; Linux and macOS; tested both in local and Vercel/production
Additional context
Root cause:
Suggested fix:
See discussion above for analysis, and user-provided stacktraces.
Contribution
Sponsor