MDX and Markdown content routes with JSX support, compiled through @mdx-js/rollup.
MDX extends Markdown with JSX, so you can use components directly in a content file. Bini.js supports .mdx and .md as page routes. Both compile through the same MDX pipeline, with full JSX, import, and export support.
| File type | Description |
|---|---|
| .mdx | Markdown with JSX components |
| .md | Markdown, compiled through the same MDX pipeline (no plain-only mode) |
The MDX compiler is included with every Bini.js project, so there is nothing to install. Add an .mdx or .md file and it compiles automatically as part of the build.
Add an .mdx file anywhere in src/app/. The file compiles to a React component and creates a URL based on its location, exactly like a page.tsx file.
Plain .md files go through the same MDX pipeline. They support JSX and imports, just like .mdx. There is no plain-markdown-only mode.
Import components, utilities, and hooks directly in MDX. Auto-imports do not apply to .mdx or .md files, so import React hooks and React Router APIs explicitly.
useState, Link, getEnv, and the rest) apply to script files only. In .mdx and .md, import what you need.CSS Modules, plain CSS imports, and Tailwind utility classes work in MDX files exactly as they do in a page.tsx file.
prose class from @tailwindcss/typography to restore typographic defaults.MDX and Markdown are for content pages. Structural files and static exports are not supported in them.
| Feature | Supported in .mdx / .md? |
|---|---|
| Page routes | Yes |
| Flat content routes | Yes |
| layout, template, loading, error, not-found, global-error, default | No - must use .tsx / .jsx / .ts / .js |
| metadata export | No - script files only |
| document export | No - script files only |
| CSS extraction | No - script files only |
layout.tsx in the same folder and export metadata from the layout, not from the MDX file..mdx and .md are identical in behavior, because both go through the same MDX compiler. Use .mdx when a file contains JSX components, and .md when it is plain Markdown. Both support JSX, so the choice is purely about file extension.
| Behavior | .mdx | .md |
|---|---|---|
| Creates a page route | Yes | Yes |
| JSX components | Yes | Yes |
| Imports and exports | Yes | Yes |
| Auto-imports | No | No |
| metadata export | No | No |
A project mixing MDX, Markdown, and script-based routes.
| File path | URL |
|---|---|
| src/app/page.tsx | / |
| src/app/about.mdx | /about |
| src/app/blog/page.mdx | /blog |
| src/app/blog/[slug].mdx | /blog/:slug |
| src/app/docs/[[...slug]]/page.md | /docs/* |
layout.tsx exports the site-wide metadata. The blog layout.tsx exports metadata for every post, including the MDX pages under it. Neither .mdx nor .md exports metadata itself.Match any number of trailing URL segments.
Control titles, descriptions, and social previews per route.
Create your first pages and wrap them in shared layouts.
Define routes with folders and page files inside them.
Define routes with flat files instead of folders.
How every route is pre-rendered to HTML at build time.
MDX and Markdown content routes with JSX support, compiled through @mdx-js/rollup.
MDX extends Markdown with JSX, so you can use components directly in a content file. Bini.js supports .mdx and .md as page routes. Both compile through the same MDX pipeline, with full JSX, import, and export support.
| File type | Description |
|---|---|
| .mdx | Markdown with JSX components |
| .md | Markdown, compiled through the same MDX pipeline (no plain-only mode) |
The MDX compiler is included with every Bini.js project, so there is nothing to install. Add an .mdx or .md file and it compiles automatically as part of the build.
Add an .mdx file anywhere in src/app/. The file compiles to a React component and creates a URL based on its location, exactly like a page.tsx file.
Plain .md files go through the same MDX pipeline. They support JSX and imports, just like .mdx. There is no plain-markdown-only mode.
Import components, utilities, and hooks directly in MDX. Auto-imports do not apply to .mdx or .md files, so import React hooks and React Router APIs explicitly.
useState, Link, getEnv, and the rest) apply to script files only. In .mdx and .md, import what you need.CSS Modules, plain CSS imports, and Tailwind utility classes work in MDX files exactly as they do in a page.tsx file.
prose class from @tailwindcss/typography to restore typographic defaults.MDX and Markdown are for content pages. Structural files and static exports are not supported in them.
| Feature | Supported in .mdx / .md? |
|---|---|
| Page routes | Yes |
| Flat content routes | Yes |
| layout, template, loading, error, not-found, global-error, default | No - must use .tsx / .jsx / .ts / .js |
| metadata export | No - script files only |
| document export | No - script files only |
| CSS extraction | No - script files only |
layout.tsx in the same folder and export metadata from the layout, not from the MDX file..mdx and .md are identical in behavior, because both go through the same MDX compiler. Use .mdx when a file contains JSX components, and .md when it is plain Markdown. Both support JSX, so the choice is purely about file extension.
| Behavior | .mdx | .md |
|---|---|---|
| Creates a page route | Yes | Yes |
| JSX components | Yes | Yes |
| Imports and exports | Yes | Yes |
| Auto-imports | No | No |
| metadata export | No | No |
A project mixing MDX, Markdown, and script-based routes.
| File path | URL |
|---|---|
| src/app/page.tsx | / |
| src/app/about.mdx | /about |
| src/app/blog/page.mdx | /blog |
| src/app/blog/[slug].mdx | /blog/:slug |
| src/app/docs/[[...slug]]/page.md | /docs/* |
layout.tsx exports the site-wide metadata. The blog layout.tsx exports metadata for every post, including the MDX pages under it. Neither .mdx nor .md exports metadata itself.Match any number of trailing URL segments.
Control titles, descriptions, and social previews per route.
Create your first pages and wrap them in shared layouts.
Define routes with folders and page files inside them.
Define routes with flat files instead of folders.
How every route is pre-rendered to HTML at build time.