← Back to Modules
@next-modular/content-module icon

@next-modular/content-module

contentv0.1.0✓ Official
mdx-renderingfrontmattercollectionssearch

@next-modular/content-module

MDX-based content management with frontmatter, collections, and dynamic rendering for Next.js.

Installation

npx next-modular add @next-modular/content-module

Usage

import { contentModule } from '@next-modular/content-module'

export const modules = [
  contentModule({
    contentDir: './content',
    collections: ['blog', 'docs'],
  }),
]

Features

  • MDX Rendering — Write content in MDX with full React component support.
  • Frontmatter — Parse YAML frontmatter for metadata (title, date, tags, etc.)
  • Collections — Organize content into typed collections with schema validation.
  • Search — Built-in content indexing for fast client-side search.

Configuration

OptionTypeDefaultDescription
contentDirstring'./content'Directory containing MDX files
collectionsstring[][]Named content collections to register
basePathstring'/content'Base URL path for content routes
searchbooleantrueEnable search indexing

Routes

The module auto-registers routes for each collection:

  • /{basePath}/{collection} — Collection listing page
  • /{basePath}/{collection}/[slug] — Individual content page

API Routes

PathMethodDescription
/api/content/searchGETSearch across all collections
/api/content/[collection]GETList items in a collection

Content File Format

---
title: My First Post
date: 2025-01-15
tags: [nextjs, tutorial]
---

# Hello World

This is an MDX file with **full React component support**.

<MyCustomComponent prop="value" />