Next.js’s official MDX integration lets you import .mdx as components and export metadata alongside content. I used @next/mdx with the App Router and kept indexing simple by importing metadata directly from each MDX file. No extra build steps, no content database, and the sitemap pulls dates straight from the MDX front‑matter.Next.js’s official MDX integration lets you import .mdx as components and export metadata alongside content. I used @next/mdx with the App Router and kept indexing simple by importing metadata directly from each MDX file. No extra build steps, no content database, and the sitemap pulls dates straight from the MDX front‑matter.

How I Built a Simple MDX Blog in Next.js and why I chose native mdx over Contentlayer

There are many ways to host blogs with Next.js but I needed something fast & simple: plain MDX files, first‑party support, and zero extra content pipelines. No Contentlayer (which is unmaintained). No next-mdx-remote. No heavy weighted CMS systems.

\

TL;DR

  • Next.js’s official MDX integration lets you import .mdx as components and export metadata alongside content.
  • See doc here: https://nextjs.org/docs/pages/guides/mdx
  • I used @next/mdx with the App Router and kept indexing simple by importing metadata directly from each MDX file.
  • No extra build steps, no content database, and the sitemap pulls dates straight from the MDX front‑matter.

\

Why MDX + App Router?

  • Content is code: The App Router treats a folder as a route and page.mdx as a component. You get layouts, streaming, and RSC benefits for free.

  • First‑party MDX: The official plugin is maintained with Next.js and plays nicely with routing, metadata, and bundling.

  • Lower cognitive load: For a small product site, I don’t want a content compiler, watcher, or a GraphQL layer. A few MDX files and some imports are enough.

    \

    The Core Setup

  1. Add the official MDX plugin and let Next treat MD/MDX as pages.

next.config.js

import createMDX from '@next/mdx';  const withMDX = createMDX({   // Add remark/rehype plugins if/when needed   options: {     remarkPlugins: [],     rehypePlugins: [],   }, });  /** @type {import('next').NextConfig} */ const nextConfig = {   ...   pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'], };  export default withMDX(nextConfig); 

\

  1. Optionally customize how MDX renders components (I kept it minimal for now):

mdx-components.tsx

import type { MDXComponents } from 'mdx/types';  export function useMDXComponents(components: MDXComponents = {}): MDXComponents {   return {     ...components,   }; } 

\

  1. Type the metadata you export from MDX so TS understands it when imported elsewhere.

src/types/mdx.d.ts

declare module '*.mdx' {   import type { ComponentType } from 'react';   const MDXComponent: ComponentType<any>;   export default MDXComponent;   export const metadata: {     title?: string;     description?: string;     date?: string;     author?: string;     tags?: string[];   }; } 

\

  1. Create a post as a route. In the App Router, a folder is your slug and page.mdx is the page.

src/app/blog/how-to-export-ig-followers-tutorial/page.mdx

export const metadata = {   title: 'How to Export Instagram Followers (CSV, Excel, JSON)',   description: 'Step-by-step guide…',   date: '2025-08-28', };  import Image from 'next/image'; 

\

  1. Build a simple index page by importing metadata straight from MDX modules.

src/app/blog/page.tsx

import Link from 'next/link'; import { metadata as igExport } from './how-to-export-ig-followers-tutorial/page.mdx';  const posts = [   {     slug: 'how-to-export-ig-followers-tutorial',     title: igExport?.title ?? 'How to Export Instagram Followers',     description: igExport?.description,     date: igExport?.date,   }, ];  export default function BlogIndexPage() {   // Render cards linking to /blog/[slug] } 

\

  1. Keep your sitemap honest by importing the same metadata for lastModified.

src/app/sitemap.ts

import type { MetadataRoute } from 'next'; import { metadata as igExportPost } from './blog/how-to-export-ig-followers-tutorial/page.mdx'; import { getURL } from '@/utils/get-url';  export default function sitemap(): MetadataRoute.Sitemap {   return [     // …other routes     {       url: getURL('blog/how-to-export-ig-followers-tutorial'),       lastModified: igExportPost?.date ? new Date(igExportPost.date) : new Date(),       changeFrequency: 'weekly',       priority: 0.7,     },   ]; } 

\

The Aha Moments (and a few gotchas)

  • MDX as modules: You can import both the rendered component and named exports (metadata) from any .mdx file. That made the blog index and sitemap trivial.
  • Keep it typed: The *.mdx module declaration means TS won’t complain when you do import { metadata } from 'some-post/page.mdx'.
  • Less is more: I didn’t reach for Contentlayer because I don’t need filesystem crawling or transformations. With a handful of posts, a tiny array is fine.

\

Contentlayer vs. Native MDX

What Contentlayer gives you:

  • Schemas and types: Define required fields and get generated TypeScript. Build fails if a post is missing a title or date.
  • Content graph: Read files from a content/ directory, compute slugs/paths, and query everything in one place.
  • Computed fields: Derive readingTime, slug, canonical URLs, etc., at build time.
  • Good for docs sites: Multiple document types (Guides, API refs, Changelogs) with strict structure.

Native MDX strengths (why I chose it here):

  • Zero ceremony: No schema layer, no background watcher — just .mdx files and imports.
  • Co‑location: The post lives at app/blog/[slug]/page.mdx, same place users will visit.
  • Good enough typing: A tiny *.mdx module declaration plus optional Zod to validate metadata if you want stricter checks.

\

Market Opportunity
RWAX Logo
RWAX Price(APP)
$0.0002396
$0.0002396$0.0002396
+2.74%
USD
RWAX (APP) Live Price Chart
Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact service@support.mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

MAXI DOGE Holders Diversify into $GGs for Fast-Growth 2025 Crypto Presale Opportunities

MAXI DOGE Holders Diversify into $GGs for Fast-Growth 2025 Crypto Presale Opportunities

Presale crypto tokens have become some of the most active areas in Web3, offering early access to projects that blend culture, finance, and technology. Investors are constantly searching for the best crypto presale to buy right now, comparing new token presales across different niches. MAXI DOGE has gained attention for its meme-driven energy, but early [...] The post MAXI DOGE Holders Diversify into $GGs for Fast-Growth 2025 Crypto Presale Opportunities appeared first on Blockonomi.
Share
Blockonomi2025/09/18 00:00
UK crypto holders brace for FCA’s expanded regulatory reach

UK crypto holders brace for FCA’s expanded regulatory reach

The post UK crypto holders brace for FCA’s expanded regulatory reach appeared on BitcoinEthereumNews.com. British crypto holders may soon face a very different landscape as the Financial Conduct Authority (FCA) moves to expand its regulatory reach in the industry. A new consultation paper outlines how the watchdog intends to apply its rulebook to crypto firms, shaping everything from asset safeguarding to trading platform operation. According to the financial regulator, these proposals would translate into clearer protections for retail investors and stricter oversight of crypto firms. UK FCA plans Until now, UK crypto users mostly encountered the FCA through rules on promotions and anti-money laundering checks. The consultation paper goes much further. It proposes direct oversight of stablecoin issuers, custodians, and crypto-asset trading platforms (CATPs). For investors, that means the wallets, exchanges, and coins they rely on could soon be subject to the same governance and resilience standards as traditional financial institutions. The regulator has also clarified that firms need official authorization before serving customers. This condition should, in theory, reduce the risk of sudden platform failures or unclear accountability. David Geale, the FCA’s executive director of payments and digital finance, said the proposals are designed to strike a balance between innovation and protection. He explained: “We want to develop a sustainable and competitive crypto sector – balancing innovation, market integrity and trust.” Geale noted that while the rules will not eliminate investment risks, they will create consistent standards, helping consumers understand what to expect from registered firms. Why does this matter for crypto holders? The UK regulatory framework shift would provide safer custody of assets, better disclosure of risks, and clearer recourse if something goes wrong. However, the regulator was also frank in its submission, arguing that no rulebook can eliminate the volatility or inherent risks of holding digital assets. Instead, the focus is on ensuring that when consumers choose to invest, they do…
Share
BitcoinEthereumNews2025/09/17 23:52
Bank of Canada cuts rate to 2.5% as tariffs and weak hiring hit economy

Bank of Canada cuts rate to 2.5% as tariffs and weak hiring hit economy

The Bank of Canada lowered its overnight rate to 2.5% on Wednesday, responding to mounting economic damage from US tariffs and a slowdown in hiring. The quarter-point cut was the first since March and met predictions from markets and economists. Governor Tiff Macklem, speaking in Ottawa, said the decision was unanimous. “With a weaker economy […]
Share
Cryptopolitan2025/09/17 23:09