motion: [BUG] Latest version incompatible with NextJS 15 build?

Hello everyone and thanks for such a nice library! 😃

Anyway, my NextJS build is failing due to an error when using latest version 12.11.1:

Runing next build throws this error:

./node_modules/framer-motion/dist/es/index.mjs
Error: It's currently unsupported to use "export *" in a client boundary. Please use named exports instead.
    at Object.transformSource (.../node_modules/next/dist/build/webpack/loaders/next-flight-loader/index.js:104:53)

Import trace for requested module:
./node_modules/framer-motion/dist/es/index.mjs

Any clue what could cause this?

My versions:

"next": "15.3.2",
"react": "19.1.0",
"react-dom": "19.1.0",

Package is at @12.11.1

Thanks

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 13
  • Comments: 24

Commits related to this issue

Most upvoted comments

We encountered it today when upgrading from 12.15.0 to 12.19.1.

It appears all import from motion/react trigger this error. We import MotionConfig, AnimatePresence.

Versions that do not trigger the error for us:

  • 12.15.0
  • 12.17.0
  • 12.18.0
  • 12.18.1

Versions that do trigger the error for us:

  • 12.18.2
  • 12.19.0
  • 12.19.1

I can reproduce this on the following CodeSandbox: https://codesandbox.io/p/devbox/2dsgl3 It is simply the default NextJS template with an added import in the layout.tsx You see the error in the build action.

🧠 What changed

In ≤ 12.18.1, motion/react exported all symbols explicitly from a "use client" file:

"use client";
export { LazyMotion, AnimatePresence, MotionConfig, ... } from "./...";

✅ This worked in Next.js App Router with React Server Components.

In 12.18.2+, that file was replaced by a one-line wrapper:

"use client";
export * from "framer-motion";

❌ This causes Next.js builds to fail with:

Error: It’s currently unsupported to use “export *” in a client boundary. Please use named exports instead.

⸝

🧐 Why this breaks in Next.js

Next.js (via React Server Components + Flight compiler) requires statically analyzable named exports from “use client” modules to build its proxy system.

export * makes the export surface dynamic, the compiler can’t resolve what’s being exported at build time, so it throws an error.

This is a known limitation of the current React Server Components architecture.

⸝

🔍 Other libraries with the same issue

This isn’t a Motion-specific bug -> it’s a pattern others have hit too:

Chakra UI - chakra-ui/chakra-ui#7878

NextUI - nextui-org/nextui#2749

wagmi - wagmi-dev/wagmi#3207

⸝

✅ Next step

@mattgperry if you’re open to it, I’m happy to submit a PR that restores compatibility with Next.js App Router by ensuring only named exports are used in “use client” files - without reverting the flattened path structure introduced in 12.18.2.

Let me know if that sounds like a good direction and I’ll get something started after the 4th of July.

Any workaround for this so i can deploy my project at least? Very frustrating!

Revert back to 12.18.1

Reverted way back to ^12.15.0 but no joy! It seems the error is coming from a Sanity related library.

Image

I LOVE motion. honestly one of the greatest libs out there. but yes sadly, this is a major issue. as soon as I update past “motion”: “12.19.0” it stops working.

I am able to fix using the same work around @RobotoSkunk mentioned above. using a wrapper to import import { domAnimation, LazyMotion } from ‘motion/react’, with the “use client” directive.

is this a pattern we need to use going forward, or are you looking to make this still work with SSR?

Getting the same error with latest version

Can you try 12.19.1?

I just tried updating to 12.19.1, but unfortunately I’m still seeing the same error during the NextJS build.

Reverting to 12.17.0 seems to fix it

I ran into the same issue, though it doesn’t seem to have broken in 12.11. If I force both motion-dom and framer-motion to 12.7.4 it works fine, but it breaks if I install 12.7.5. I’m not depending directly on framer-motion myself, but transitively through sanity-packages.

I’m seeing it via sanity as well:

Import trace for requested module:
./node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@1.2.2_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/index.mjs
./node_modules/.pnpm/sanity@3.91.0_@emotion+is-prop-valid@1.2.2_@types+node@22.15.29_@types+react@19.1.3_imm_e59b97ccbf1c2ad11a5d9f7ac96d3be9/node_modules/sanity/lib/index.mjs

I ran into the same issue, though it doesn’t seem to have broken in 12.11. If I force both motion-dom and framer-motion to 12.7.4 it works fine, but it breaks if I install 12.7.5. I’m not depending directly on framer-motion myself, but transitively through sanity-packages.