How can I handle errors with next-mdx-remote/rsc? #376
Labels
needs-investigation
might be a bug but requires further investigation
support
questions requesting support
Hi,
I'm using MDXRemote from "next-mdx-remote/rsc" package as I'm developing with Next.js 13 on a server component. I'm fetching the data from database which could be NOT a valid MDX file. I'm using it for user biographies. So maybe users put just plain text or raw html or MDX.
The problem that I face is when I use an invalid MDX file, I get errors and I can't use try catch for handling it because the error throws from MDXRemote itself. Also, I read in the documentation that I can't use serialize function as I'm using it on a server component (next-mdx-remote/rsc).
So, how can I handle errors?
Here is an example:
When the user save an invalid MDX like this one:
[Stackoverflow The Key](https://stackoverflow.blog/2021/03/31/the-key-copy-paste/){:target="_blank" rel="noopener"}
The page shows up with this error:
How can I handle errors when I'm using MDXRemote from next-mdx-remote/rsc on a server component?
Thank you!
The text was updated successfully, but these errors were encountered: