How to use MDXProvider in RSC (React Server Components) for SSG (static site generation)? #2641
-
I am using When I add ...
export default defineConfig({
plugins: [
mdx({
providerImportSource: '@mdx-js/react'
}),
... Vite reports the following error:
I assume this is because How to use MDXProvider in RSC (React Server Components) / SSG (static site generation)? Or how to define "implicit" components in SSG? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You are correct. You canβt use context providers in RSC. Next.js allows users to define the file |
Beta Was this translation helpful? Give feedback.
You are correct. You canβt use context providers in RSC.
Next.js allows users to define the file
mdx-components.tsx
. Users can exportuseMdxComponents()
from that file. Next.js uses a Webpack alias matching theproviderImportSource
option to resolve it. You can implement the same pattern for any other bundler.