Using mdx provider in a server component #50897
Replies: 4 comments 12 replies
-
Couldn't the components live in another module which could use the 'use client' directive? Also in your first block, I didn't use the same package, but here you can see the next-remote-mdx approach:
|
Beta Was this translation helpful? Give feedback.
-
Hello, One case of this use I want to do is all images have to use the Image component, list styles this way.. etc. That way I dont have to manually repeat the same thing over and over again in the MDX files.
I have also included a mdx-components.js
But all it keeps ignoring the configurations I do and just render the content without applying the style. |
Beta Was this translation helpful? Give feedback.
-
I don't know if you still are looking for answer. But I found that MDX cannot be used in server component is caused by
next.js/packages/next-mdx/index.js Lines 24 to 28 in 87b66f6 To work around it, you can set Create Use the example from https://nextjs.org/docs/app/building-your-application/configuring/mdx. You don't need import type { MDXComponents } from 'mdx/types'
// This file allows you to provide custom React components
// to be used in MDX files. You can import and use any
// React component you want, including components from
// other libraries.
// This file is required to use MDX in `app` directory.
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
// Allows customizing built-in components, e.g. to add styling.
// h1: ({ children }) => <h1 style={{ fontSize: "100px" }}>{children}</h1>,
...components,
}
} Then you should able to import |
Beta Was this translation helpful? Give feedback.
-
Also having this issue |
Beta Was this translation helpful? Give feedback.
-
Summary
So basically, how can i handle my custom components here:
page.js
next.config.mjs:
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions