Skip to content

Error in Ai module in blocknote, not work with nextjs and ai-sdk #2099

@ruimarcosjoao

Description

@ruimarcosjoao

Describe the bug

When trying to use @blocknote/xl-ai in a Next.js 15.5.5 project (React 19 + Turbopack), the build fails with the following error:

Export default doesn't exist in target module

./node_modules/.pnpm/@ai-sdk+react@2.0.70_react@19.1.0_zod@4.1.12/node_modules/@ai-sdk/react/dist/index.mjs:338:1
Export default doesn't exist in target module
  336 | } from "ai";
  337 | import { useCallback as useCallback3, useId as useId2, useRef as useRef3, useState as useState2 } from "react";
> 338 | import useSWR2 from "swr";
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^

The error continues with:

The export default was not found in module node_modules/swr/dist/index/react-server.mjs [app-rsc].
Did you mean to import unstable_serialize?

This breaks the build and prevents using the @blocknote/xl-ai module.

It seems that @ai-sdk/react (a dependency of @blocknote/xl-ai) is still importing SWR as a default export:

import useSWR from "swr";

but in swr@2.3.6 (and later), there is no default export, only named exports.
This causes the build to fail under ESM + Turbopack (Next.js 15).


To Reproduce

  1. Create a new Next.js 15 project (React 19, Turbopack enabled).

  2. Install dependencies:

    pnpm add @blocknote/core @blocknote/mantine @blocknote/react @blocknote/xl-ai ai
  3. Use the following code in app/editor/page.tsx:
    (your provided code here)

  4. Run pnpm run build or next build.

Result:
Build fails with:

Export default doesn't exist in target module (swr)

Misc

  • Node version: 22
  • Package manager: pnpm
  • Browser: Firefox and Edge

Notes / Possible Fix

  • Likely cause: @ai-sdk/react imports useSWR as a default export, but swr@2.x only provides named exports.

  • Possible workaround: lock SWR to version ^1.3.0.

  • A long-term fix would be updating @ai-sdk/react to use:

    import { useSWR } from "swr";
  • The problem only appears with Next.js 15 + React 19 + Turbopack (ESM) builds.


Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions