Skip to content

Server export '@blocknote/xl-ai/server' is marked as 'use client' and breaks server integration #2841

@zuber-dwellfi

Description

@zuber-dwellfi

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

  1. Import '@blocknote/xl-ai/server' in a Next.js API route or Node.js script
  2. Attempt to use any utility (e.g. injectDocumentStateMessages)
  3. 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

  • I'd be interested in contributing a fix for this issue

Sponsor

  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue has not yet been reviewed or classified by maintainers.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions