nextjs-mdx-presentation
Build MDX-driven presentation systems in Next.js where AI outputs .mdx files that compose prebuilt slide components. Includes deck engine, slide components (TitleSlide, ContentSlide, TwoColumn, etc.), Framer Motion transitions, presenter mode with speaker notes, theme system, keyboard controls, and PDF export. Use for creating presentation frameworks or generating slide decks.
Next.js MDX Presentation System
Build presentation systems where MDX is the API: AI outputs .mdx files that compose prebuilt slide components. This creates a lightweight, controllable deck engine optimized for Next.js App Router.
⚠️ MUST READ FIRST
Before implementing anything, read CRITICAL-PATTERNS.md - Contains non-negotiable patterns for:
- Full-screen slides (NO small cards!)
- Maximized images (NO tiny charts with borders!)
- Circular gradient overlays
- Three required themes (Corporate, Academic, Minimal)
- Color contrast rules
Common mistakes that make presentations look unprofessional:
- Using
max-w-6xl aspect-[16/9]instead of full screen - Adding borders/shadows to images
- White text on white backgrounds
- Missing circular overlays
When to Use This Skill
- User asks to build a presentation system or slide framework
- User wants to create slide decks programmatically
- User needs presenter tools (speaker notes, preview, timer)
- User requests themed presentations with consistent styling
- User mentions frameworks like Reveal.js, Spectacle, or MDX Deck
Core Concept
MDX as API: The AI (or author) writes MDX that imports and composes slide components. The deck engine handles navigation, transitions, and presentation features.
Architecture Overview
/app/presentations/[slug]/page.tsx # Audience view
/app/presentations/presenter/[slug]/ # Presenter console
/components
/deck # Engine: DeckProvider, DeckViewport, Keyboard, Steps
/slides # Components: TitleSlide, ContentSlide, TwoColumn, etc.
/lib
mdx-deck.ts # Parse MDX, split slides by `---`, compile with rehype
/content/decks/<slug>/index.mdx # Deck files
Prerequisites
Required packages:
Quick Start Workflow
1. Create Core Infrastructure
Deck Provider (components/deck/DeckProvider.tsx):
- Manages slide index state
- Syncs with
?slide=nURL param - Provides
next(),prev(),set(n)navigation
Deck Viewport (components/deck/DeckViewport.tsx):
- Renders slides in aspect-ratio container (16:9, 4:3, 9:16)
- Animates transitions with Framer Motion
- Uses
AnimatePresencefor smooth slide changes
Keyboard Controls (components/deck/Keyboard.tsx):
- Arrow keys, Space, Home, End navigation
- Respect reduced-motion preference
2. Create Slide Components
Build atomic slide layouts as React components:
- TitleSlide: Hero slide with title/subtitle
- ContentSlide: Title + body content
- TwoColumn: Left/right split layout
- ImageSlide: Full image with caption
- QuoteSlide: Centered blockquote
See references/components-guide.md for detailed component patterns.
3. MDX Compilation Pipeline
lib/mdx-deck.ts:
- Load deck file from
content/decks/<slug>/index.mdx - Parse frontmatter (title, author, theme, aspect)
- Split content by
\n---\ndelimiter - Compile each slide section with
next-mdx-remote - Apply rehype plugins (syntax highlighting, slugs, links)
- Return
{ meta, slides }object
4. Deck Route
Essential Features
Steps/Appear Animation
Reveal content incrementally within a slide:
Track step progress in useDeck() hook, animate with Framer Motion.
Presenter Mode
Presenter console (/presentations/presenter/[slug]):
- Grid layout: current slide (large) + next slide (preview)
- Speaker notes area with
<Notes>portal - Timer and slide counter
Notes component: Uses React portal to render notes in presenter view while hiding in audience view.
Theme System
Body classes from frontmatter:
CSS variables (globals.css):
See references/theming-guide.md for complete theme documentation.
Print/PDF Export
Print stylesheet:
Users print to PDF via browser. Optional: create /print/[slug] route with paginated layout.
Component API for MDX Authors
Export components in components/mdx-slide-components.tsx:
These become available in MDX:
Deep Linking & Navigation
- URL format:
/presentations/my-deck?slide=3 - Keyboard: ←/→ (prev/next), Space (next), Home (first), End (last)
- Progress bar: Visual indicator with click-to-jump
- Optional mini-map: Thumbnail navigation grid
Accessibility
role="presentation"on deck container- Focus management: trap focus within current slide
- Keyboard navigation without mouse dependency
- Respect
prefers-reduced-motionfor transitions - ARIA labels on controls
AI Output Contract
When AI generates a deck, it should produce:
Progressive Implementation Strategy
Phase 1 (MVP):
- Deck provider with navigation state
- Basic slide components (Title, Content)
- MDX compilation pipeline
- Keyboard controls
Phase 2: 5. Framer Motion transitions 6. Steps/Appear incremental reveal 7. Theme system (3 presets) 8. Progress bar
Phase 3: 9. Presenter mode with notes 10. Print/PDF support 11. Advanced components (TwoColumn, Image, Quote) 12. Mini-map navigation
Bundled Resources
References (references/)
Load these when implementing specific features or needing detailed guidance:
- setup-guide.md - Complete setup instructions, dependency configuration, and project structure
- components-guide.md - Detailed component patterns and API documentation for all slide types
- theming-guide.md - Theme system, CSS variables, and customization patterns
Assets (assets/)
Copy-paste ready templates and boilerplate:
- deck-template/ - Complete working example deck with all slide types and features
- component-templates/ - Boilerplate code for creating custom slide components
Scripts (scripts/)
Automation utilities:
- init-presentation.sh - Automated project setup script
Common Patterns
Multi-step reveal:
Synchronized views:
Custom transitions:
Validation Checklist
- Decks load from
content/decks/<slug>/index.mdx - Slides split by
---delimiter -
?slide=ndeep linking works - Keyboard navigation (arrows, space, home, end)
- Framer Motion transitions respect reduced-motion
- Steps/Appear reveal items incrementally
- Presenter mode shows current + next + notes
- Syntax highlighting with rehype-pretty-code
- Themes switch via frontmatter
- Aspect ratios enforced (16:9, 4:3, 9:16)
- Print/PDF renders one slide per page
- Basic a11y: focus management, ARIA roles
Tips for AI-Generated Decks
- Consistent structure: Always use frontmatter, imports, and
---delimiters - Semantic components: Choose slide types that match content (TitleSlide for covers, ContentSlide for bullets, etc.)
- Step through reveals: Use
<Steps>for progressive disclosure of complex ideas - Speaker notes: Add
<Notes>with context, timing, or talking points - Theme selection: Match theme to content (academic for research, corporate for business, minimal for tech talks)
Troubleshooting
Slides not splitting: Ensure delimiter is exactly \n---\n (newline, three hyphens, newline)
Components not found: Verify exports in mdx-slide-components.tsx and imports in MDX
Transitions janky: Check prefers-reduced-motion, ensure AnimatePresence wraps slides
Theme not applying: Confirm body class matches CSS variable definitions
Print broken: Test @media print styles, verify @page size matches aspect ratio