Skip to Content
🎉 Nextra 4.0 is released. dimaMachina is looking for a new job or consulting .
APIcompileMdx

compileMdx Function

Exported from nextra/compile.

Signature

Parameters:
NameTypeDefault
rawMdxstring
[1]?.staticImageboolean
[1]?.searchboolean | { codeblocks: boolean; }
[1]?.defaultShowCopyCodeboolean | undefined
[1]?.readingTimeboolean | undefined
[1]?.latexboolean | { options?: { src?: string | undefined; config?: MathJaxConfig | undefined; } | undefined; renderer: "mathjax"; } | { renderer: "katex"; options: rehype_katex_lib_index_js.Options; } | undefined
[1]?.codeHighlightboolean
[1]?.whiteListTagsStylingstring[] | undefined
[1]?.mdxOptions{ rehypePlugins?: PluggableList | null | undefined; remarkPlugins?: PluggableList | null | undefined; recmaPlugins?: PluggableList | null | undefined; format?: "detect" | ... 1 more ... | "md"; rehypePrettyCodeOptions?: Options; } & Pick<...>{}
[1]?.filePathstring''
[1]?.useCachedCompilerboolean
[1]?.isPageImportbooleanfalse
[1]?.lastCommitTimenumber
Returns:
Promise<string>

Example

// Usage with MDXRemote import { compileMdx } from 'nextra/compile' import { MDXRemote } from 'nextra/mdx-remote' const rawJs = await compileMdx(rawMdx) const content = <MDXRemote compiledSource={rawJs} components={...} scope={...} />