How to run compiled MDX without calling the Function constructor? #2322
-
Hello there! I've been trying to use mdx with nextjs hosted on the edge. Unfortunately, it happens that on the edge, But running Is there an otherway to get mdx in react without those apis? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Yes, MDX generates JavaScript. Something needs to run that JavaScript. |
Beta Was this translation helpful? Give feedback.
rehype produces HTML, which doesn't run, and is purely rendered in browser.
MDX produces JavaScript, it can be run either on the browser or the server, when it is run it produces HTML.
If you want to run it on the server, you need a way to dynamically run JavaScript, like:
eval
,new Function
, or a dynamic import.