Next.js Discord

Discord Forum

can't import default argument in production

Unanswered
Western Kingbird posted this in #help-forum
Open in Discord
Western KingbirdOP
I am trying to import the default function returned by the mdx file dynamically
const Content = (await import(`/content/docs/${params.slug}.mdx`)).default;

It's returning some jsx as you can see in the image. it works perfectly in local environment. But I can't seem to make it work in production. Even when I just run
const Content = (await import(`/content/docs/${params.slug}.mdx`));

this works but I only get metaData in production. I don't get default. in my local environment I get both.

2 Replies

Western KingbirdOP
I can't render it if I don't export it as default and export it in a named function
it doesnt return MDXcontent