โ–ฒ

Blog with Next.js + MDX

๐Ÿ‘จโ€๐Ÿณ Chefโฑ๏ธ 40 minutes

๐Ÿ“‹ Suggested prerequisites

  • โ€ขBasic Next.js
  • โ€ขMarkdown

What you'll build

A personal blog with Next.js where you write posts in Markdown files and static pages are automatically generated with friendly URLs. You'll have a main page listing all your posts with title, date, and tags, each post with syntax highlighting for code and the ability to use React components inside Markdown. The site will be ultra-fast because it's statically generated (SSG) and you can deploy it for free on Vercel.


Step 1: Ask an AI for the blog

I need a blog with Next.js that:
- Uses MDX for posts
- Has a page listing all posts
- Each post has metadata (title, date, tags)
- Syntax highlighting for code
- Generates static routes (SSG)
- TypeScript and Tailwind CSS

Give me the complete structure with 2 example posts.

Structure

app/
โ”œโ”€โ”€ blog/
โ”‚   โ”œโ”€โ”€ page.tsx          # Post list
โ”‚   โ””โ”€โ”€ [slug]/
โ”‚       โ””โ”€โ”€ page.tsx      # Individual post
content/
โ”œโ”€โ”€ posts/
โ”‚   โ”œโ”€โ”€ hello-world.mdx
โ”‚   โ””โ”€โ”€ second-post.mdx

MDX example

---
title: "My First Post"
date: "2026-01-01"
tags: ["nextjs", "tutorial"]
---

# Welcome

This is my first post with **MDX**.

<CustomComponent prop="value" />

\`\`\`typescript
const greeting = "Hello world!"
\`\`\`

Useful libraries

LibraryWhat for
@next/mdxMDX in Next.js
gray-matterParse frontmatter
rehype-highlightSyntax highlighting

Next step

โ†’ Auth with Firebase Google