Next.js Project Setup Guide

Next.js Project Setup Guide

A step-by-step guide to set up a modern Next.js project with all the essential features.

1. Create Next.js App

Option 1: Interactive Setup

Terminal

Follow the prompts to configure your project.

Example with TypeScript, Tailwind CSS, App Router, Turbopack:

Terminal

2. Install shadcn/ui

Initialize shadcn/ui in your project:

Terminal

Add components individually or all at once:

Terminal

Use the toggle option to select all components when prompted.

3. Add Framer Motion (Optional)

For smooth animations and transitions:

Terminal

4. Theme Switching with next-themes

Install next-themes for theme management:

Terminal

Create Theme Provider

Create components/theme-provider.tsx:

components/theme-provider.tsx

Wrap Your App

Update app/layout.tsx to include the ThemeProvider:

app/layout.tsx

5. Setup MDX Support

MDX allows you to write JSX in your markdown files.

Install Dependencies

Terminal

Configure next.config.ts

Update your next.config.ts:

next.config.ts

Create components

Create components/mdx-image.tsx in your project:

components/mdx-image.tsx

Create components/mdx-syntax-highlighter.tsx in your project root:

components/mdx-syntax-highlighter.tsx

Create mdx-components.tsx in your project root:

mdx-components.tsx

6. MDX Setup Options

Option A: Static MDX Pages

Create MDX files directly in your app directory:

Directory Structure

Create app/blog/page.mdx:

app/blog/page.mdx

Option B: Dynamic MDX with Slugs

For dynamic blog posts with slug-based routing:

Directory Structure

Create app/blog/[slug]/page.tsx:

app/blog/[slug]/page.tsx

Create content/posts/first-post.mdx:

content/posts/first-post.mdx

7. Run Your Project

Start the development server:

Terminal

Your app will be available at http://localhost:3000

Summary

You now have a fully configured Next.js project with:

✅ TypeScript and Tailwind CSS
✅ shadcn/ui components
✅ Dark mode with next-themes
✅ Smooth animations with framer-motion
✅ MDX support for both static and dynamic content

Happy coding! 🚀