# Hello, MDX!
This is an MDX file.
Parcel detects dependency references in MDX files and processes them as well. These references are re-written so that they link to the correct output files. Supported dependencies include:
Links to other pages can be created with the Markdown link syntax or the HTML <a>
element.
This is a [link](another-page.mdx).
This is <a href="somewhere.html">another link</a>
Images can be referenced using the Markdown image syntax, HTML <img>
element, or <picture>
` element. See the HTML docs for more details.

<img src="another-image.png">
The <video>
, <audio>
, <track>
, <embed>
, <object>
, and <iframe>
elements are supported. The referenced URLs are processed by Parcel and rewritten to include a content hash.
Parcel supports customizing how code blocks are rendered by specifying your own CodeBlock
component. This allows you to implement syntax highlighting and other features.
import Hello from './hello.mdx';
const components = {CodeBlock};
export function App() {
return <Hello components={components} />;
}
function CodeBlock({lang, children}) {
return (
<pre>
<code className={lang ? `language-${lang}` : null}>
{syntaxHighlight(children)}
</code>
</pre>
);
}
function syntaxHighlight() {
// ...
}
Markdown code fences accept arbitrary props, which are parsed as JSX and passed into the CodeBlock
component.
```tsx boolean string="hi" number={2}
console.log("hi");
```
The above example compiles to:
<CodeBlock lang="tsx" boolean string="hi" number={2}>
console.log("hi");
</CodeBlock>
Markdown code fences in JavaScript, TypeScript, and CSS support running the code live and rendering the result inline. Set the render
prop on the code fence to pass the result of the code block to the <CodeBlock>
component. For example:
```tsx render
<div>Hello world!</div>
```
would render
<CodeBlock lang="tsx" render={<div>Hello world!</div>}>
<div>Hello world!</div>
</CodeBlock>
The provided CodeBlock
component can choose where to display the rendered value. The default implementation renders it after the <pre>
element.
<pre>
<code class="lang-tsx">
<div>Hello world!</div>
</code>
</pre>
<div>Hello world!</div>