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

MDX in app router causes - "error createContext only works in Client Components" #50110

Closed
1 task done
MatthewCaseres opened this issue May 21, 2023 · 3 comments
Closed
1 task done
Labels
examples Issue/PR related to examples

Comments

@MatthewCaseres
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.1.0: Sun Oct  9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 19.6.0
      npm: 9.4.0
      Yarn: N/A
      pnpm: 8.4.0
    Relevant packages:
      next: 13.4.4-canary.0
      eslint-config-next: 13.4.3
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.4

Which example does this report relate to?

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

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When I follow the documentation for using MDX with app router, I get the following error -

- error node_modules/@mdx-js/react/lib/index.js (34:26) @ React
- error createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(sc_server)/./node_modules/@mdx-js/react/lib/index.js:38:73)
    at (sc_server)/./node_modules/@mdx-js/react/lib/index.js (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/app/page.js:2273:1)
    at __webpack_require__ (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(sc_server)/./src/app/hello.mdx:7:85)
    at (sc_server)/./src/app/hello.mdx (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/app/page.js:286:1)
    at __webpack_require__ (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(sc_server)/./src/app/page.tsx:7:68)
    at (sc_server)/./src/app/page.tsx (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/app/page.js:2163:1)
    at Function.__webpack_require__ (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/webpack-runtime.js:33:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  name: 'TypeError',
  digest: undefined
}
null
- error node_modules/@mdx-js/react/lib/index.js (34:26) @ React
- error createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(sc_server)/./node_modules/@mdx-js/react/lib/index.js:38:73)
    at (sc_server)/./node_modules/@mdx-js/react/lib/index.js (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/app/page.js:2273:1)
    at __webpack_require__ (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(sc_server)/./src/app/hello.mdx:7:85)
    at (sc_server)/./src/app/hello.mdx (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/app/page.js:286:1)
    at __webpack_require__ (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(sc_server)/./src/app/page.tsx:7:68)
    at (sc_server)/./src/app/page.tsx (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/app/page.js:2163:1)
    at Function.__webpack_require__ (/Users/matthewcaseres/Documents/GitHub/mdx-repro/.next/server/webpack-runtime.js:33:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  name: 'TypeError',
  digest: undefined
}
null

Expected Behavior

I should be able to use MDX.

To Reproduce

https://github.com/MatthewCaseres/mdx-repro

@holahoon
Copy link

holahoon commented Jun 7, 2023

were you able to resolve your issue?

@MatthewCaseres
Copy link
Author

yeah I closed the issue after some discussion in this thread - #47523

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples
Projects
None yet
Development

No branches or pull requests

2 participants