-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using MDXRemote in a client component gives Error: Element type is invalid #480
Comments
+1 |
This broke when going from Next.js 14.1.4 to 14.2. I was able to workaround the error by switching to https://github.com/ipikuka/next-mdx-remote-client instead. It's a fork of https://github.com/hashicorp/next-mdx-remote so isn't a drop in replacement, but it wasn't difficult to switch. Server side I switched from import { hydrate } from "next-mdx-remote-client";
// ...
const { content, mod, error } = hydrate({ ...content, components }); You can then get the context in the component with I just deployed this to https://console.dev in consoledotdev/home#572 |
@davidmytton Saved my life lol, Cheers! |
As the author of |
Describe the bug
In a NextJS application, when I use MDXRemote within a client component, the console shows the following error:
Internal error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
The error above occurs on production build as well.
How to reproduce:
next
: v14.2.10typescript
: v5.1.6next-mdx-remote
: v4.4.1 (happens on v5.0.0 as well)app/test/page.tsx
)TestComponent
component/test-mdx
Note: the example above is just a simple way to reproduce the problem I had. Some of you might suggest importing from
next-mdx-remote/rsc
and in fact, the error above did not occur in the server component setup. But in my real application, I have to use MDXRemote within a client component, that's why I created the code above to test. It turned out that the simple setup above is enough to get the error (at first I thought it was because of the custom components that I pass intoMDXRemote
).Reproduction
https://github.com/ChunML/next-mdx-error
next-mdx-remote version
v4.4.1 (can reproduce on v5.0.0 too)
The text was updated successfully, but these errors were encountered: