Skip to content

next-mdx-remote 6 drops object-valued JSX props: <Sandpack files={{…}}> compiles with zero files #554

Description

@ShreeBohara

Summary

Since the bump to next-mdx-remote 6.0.0 (ff889a1), object-valued JSX attributes written in MDX no longer reach the component. <Sandpack files={{ '/App.tsx': '…' }} /> is compiled with files === {}.

This has two different symptoms depending on whether the block also sets template:

  1. Hard build failure when there is no template. SandpackProvider throws Error: [sandpack-react]: without a template, you must pass at least one file, which aborts the whole static export.
  2. Silent data loss when there is a template. The page builds, and the Sandpack renders with none of the authored files.

folder="…" is unaffected — those files are read from disk in the RSC and still resolve.

Impact

Symptom 1 is currently breaking downstream docs deploys. react-three-fiber's "Build documentation and deploy to GitHub Pages" has failed on every run since 2026-07-30 (its first push to master after the bump); the last green run was 2026-05-06. Example failure, on /getting-started/introduction: https://github.com/pmndrs/react-three-fiber/actions/runs/30643760945

Symptom 2 applies to this repo's own docs. Every files={{…}} example in docs/authoring/sandpack.mdx also passes template="react-ts", so they build without error and render empty — which is likely why CI here has stayed green.

Note that consumers run the published ghcr.io/pmndrs/docs:3 image via build.yml@v3, so a fix needs a new image publish to reach them.

Reproduction

git clone https://github.com/pmndrs/docs && cd docs
git clone https://github.com/pmndrs/react-three-fiber ../r3f && cp -R ../r3f/docs extdocs
pnpm install
MDX=extdocs OUTPUT=export DIST_DIR=extdocs/out BASE_PATH="" \
  HOME_REDIRECT=/getting-started/introduction \
  NEXT_PUBLIC_LIBNAME="React Three Fiber" \
  MDX_BASEURL=https://github.com/pmndrs/react-three-fiber/raw/master/docs \
  pnpm build
Error occurred prerendering page "/getting-started/introduction"
Error: [sandpack-react]: without a template, you must pass at least one file
Export encountered an error on /[...slug]/page: /getting-started/introduction, exiting the build.

The block that throws is the TypeScript example in docs/getting-started/introduction.mdx, which passes files={{ '/styles.css': …, '/index.tsx': … }} and no template.

Diagnosis

Logging the props Sandpack actually receives, at the top of src/components/mdx/Sandpack/Sandpack.tsx:

With next-mdx-remote 6.0.0 — inline files arrive empty, folder still resolves:

{"folder":null,"propsFilesKeys":[],"resolvedFileKeys":[],"template":null}
{"folder":"…/getting-started/basic-example-sandpack","propsFilesKeys":[],"resolvedFileKeys":["/index.jsx","/styles.css"],"template":null}

With next-mdx-remote 5.0.0, same source and same MDX:

{"folder":null,"propsFilesKeys":["/styles.css","/index.tsx"],"resolvedFileKeys":["/styles.css","/index.tsx"],"template":null}

Building this repo's own docs (MDX=docs) on 6.0.0 shows symptom 2 — the authored files are gone, but template keeps it from throwing:

{"folder":null,"propsFilesKeys":[],"resolvedFileKeys":[],"template":"react-ts"}

What isolates it

Source next-mdx-remote Result
v3 tip 6.0.0 (lockfile) fails on /getting-started/introduction
b06e545 (2026-05-07, pre-bump) 5.0.0 25/25 pages
v3 tip 5.0.0 (pinned) 25/25 pages

Same source at the tip passes or fails purely on the next-mdx-remote major, which points at the upgrade rather than at anything in src/.

I have not worked out which v6 change drops the attribute — whether compileMDX needs different options now, or whether this is an upstream regression worth reporting there. Happy to dig further or put up a PR if you have a preferred direction.

Environment

  • pmndrs/docs v3 @ 6469729, and b06e545 for the passing comparison
  • Node 20.19.0, pnpm 10.28.1, macOS arm64
  • next-mdx-remote 6.0.0 vs 5.0.0, @codesandbox/sandpack-react 2.20.0 (unchanged across both)
  • MDX under test: react-three-fiber master docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions