Skip to content
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

Docs: Clarify that @next/mdx can replace next-mdx-remote #70179

Open
karlhorky opened this issue Sep 17, 2024 · 0 comments
Open

Docs: Clarify that @next/mdx can replace next-mdx-remote #70179

karlhorky opened this issue Sep 17, 2024 · 0 comments
Labels
Documentation Related to Next.js' official documentation.

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Sep 17, 2024

What is the documentation issue?

Since a few months / years, I have encountered articles such as MDX in Next.js - Space Jelly by @colbyfayock which are based on the (incorrect) assumption that @next/mdx cannot pull in content from other sources such as files outside of the app directory:

The trick here though is that to use the official Next.js MDX package, our content needs to be located inside of the app directory, just like any other page file.

But in our example, say we have a content directory in the root of our project with a dump of our MDX, and it’d be tedious, and frankly a bit overwhelming to put that all inside of the app directory with the page filename pattern, we can instead use Next MDX Remote to render our content from where it is.

This is an incorrect assumption, as files outside of the app directory can be pulled in via static imports and dynamic import():

  1. static import
  2. dynamic import()

Apart from the aforementioned blog posts, there seems to be a bunch of community confusion on what is possible using @next/mdx:

Even the Next.js MDX docs section "Remote MDX" seem to (incorrectly) implicitly indicate that @next/mdx cannot do this:

If your MDX files or content lives somewhere else, you can fetch it dynamically on the server. This is useful for content stored in a separate local folder, CMS, database, or anywhere else. A popular community package for this use is next-mdx-remote.

@next/mdx can achieve the same things as next-mdx-remote and mdx-bundler and rsc-mdx, without the significant, non-obvious downsides with the alternatives:

cc @manovotny @leerob @wooorm @remcohaszing

Is there any context that might help us understand?

I'm hoping the context is included above. I can add more if needed.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/building-your-application/configuring/mdx

@karlhorky karlhorky added the Documentation Related to Next.js' official documentation. label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Related to Next.js' official documentation.
Projects
None yet
Development

No branches or pull requests

1 participant