How to Use Nextra Docs and Deploy It to Vercel: A Step-by-Step Guide

Discover how to use Nextra Docs to create modern documentation sites and deploy them to Vercel. This tutorial covers setup, customization, and tips!

Ashley Goolam

Ashley Goolam

12 June 2025

How to Use Nextra Docs and Deploy It to Vercel: A Step-by-Step Guide

If you want to create a sleek, modern documentation website with ease, Nextra Docs is one of the best tools available. Built on top of Next.js, Nextra lets you write your documentation in Markdown or MDX, customize the look and feel, and deploy it effortlessly—especially on Vercel. In this article, we’ll walk through how to set up a Nextra Docs site from scratch and deploy it to Vercel for free.

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

What Are Nextra Docs? Your Doc-Building BFF

Nextra docs is a Next.js-based framework that makes creating documentation sites a breeze. It’s all about Markdown (or MDX) content with a pre-built Docs Theme that packs navigation, search, and a table of contents out of the box. Here’s why nextra docs rocks:

Users rave about nextra docs for its “zero-config polish” and Vercel deploys. Ready to build your site? Let’s dive in!

Why Use Nextra Docs with Vercel?

Nextra docs is perfect for devs, startups, or open-source projects needing pro-level documentation fast. Pairing it with Vercel—Next.js’s home turf—means:

I deployed a test site to Vercel, and it was live in under 5 minutes—smooth as butter!

How to Set Up Nextra Docs: Step-by-Step Guide

Let’s create a nextra docs site from scratch using Next.js’s app router. Follow along, and you’ll have a local site running in ~20 minutes!

1. Create a New Next.js Project

npx create-next-app my-nextra-docs
next js project options
cd my-nextra-docs

2. Install Nextra Docs Dependencies

Install the core packages for nextra docs:

npm install next react react-dom nextra nextra-theme-docs

3. Update package.json Scripts

Ensure package.json includes these scripts (they’re usually added by create-next-app):

"scripts": {
  "dev": "next",
  "build": "next build",
  "start": "next start"
}
"dev": "next --turbopack"
package.json
npm run dev

Visit http://localhost:3000 to confirm the Next.js app works.

next js home page

Ugly:( But well, it works! Now let's try and fix this.

4. Configure Nextra Docs

import nextra from 'nextra'

const withNextra = nextra({
  theme: 'nextra-theme-docs',
  themeConfig: './theme.config.js'
})

export default withNextra({
  async redirects() {
    return [
      {
        source: '/',
        destination: '/resources',
        permanent: true
      }
    ]
  }
})
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "next.config.mjs", ".next/types/**/*.ts"]

5. Set Up MDX Components

import { useMDXComponents as getThemeComponents } from 'nextra-theme-docs'

const themeComponents = getThemeComponents()

export function useMDXComponents(components) {
  return {
    ...themeComponents,
    ...components
  }
}

6. Update the App Layout

import { Footer, Layout, Navbar } from 'nextra-theme-docs'
import { Banner, Head } from 'nextra/components'
import { getPageMap } from 'nextra/page-map'
import 'nextra-theme-docs/style.css'
 
export const metadata = {
  // Define your metadata here
  // For more information on metadata API, see: https://nextjs.org/docs/app/building-your-application/optimizing/metadata
}
 
const banner = <Banner storageKey="some-key">Nextra 4.0 is released 🎉</Banner>
const navbar = (
  <Navbar
    logo={<b>Nextra</b>}
    // ... Your additional navbar options
  />
)
const footer = <Footer>MIT {new Date().getFullYear()} © Nextra.</Footer>
 
export default async function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html
      // Not required, but good for SEO
      lang="en"
      // Required to be set
      dir="ltr"
      // Suggested by `next-themes` package https://github.com/pacocoursey/next-themes#with-app
      suppressHydrationWarning
    >
      <Head
      // ... Your additional head options
      >
        {/* Your additional tags should be passed as `children` of `<Head>` element */}
      </Head>
      <body>
        <Layout
          banner={banner}
          navbar={navbar}
          pageMap={await getPageMap()}
          docsRepositoryBase="https://github.com/shuding/nextra/tree/main/docs"
          footer={footer}
          // ... Your additional layout options
        >
          {children}
        </Layout>
      </body>
    </html>
  )
}

7. Add Documentation Pages

home page 404 error message
/app/resources
  /page.mdx

For testing purposes, I added:

# Resources

Resources related to various topics and fields.

## Learning
- [Build Your Own X](https://github.com/codecrafters-io/build-your-own-x): Master programming by recreating your favourite technologies from scratch.

## Useful Articles
- [CSR vs SSR vs SSG vs ISR: A Deep Dive for Modern Web Development](csr-vs-ssr-vs-ssg-vs-isr-a-deep-dive-for-modern-web-development-33kl#:~:text=Here's%20a%20quick%20summary%3A,as%20SPAs%2C%20CSR%20is%20perfect.)
- [The Art of Comand Line](https://github.co./jlevy/the-art-of-command-line)

But the content does not need to be complex and can be as simple as:

# Getting Started

Hi <Your Name>! Welcome to your **nextra docs** site:)

- Easy Markdown editing
- Automatic navigation
- Search and TOC built-in
nextra home page

Go ahead - edit this page, add more pages, and try out all the features like dark/light mode. The power is in your hands, and the options are endless!

light and dark mode

Deploying Nextra Docs to Vercel

Now, let’s get your nextra docs site live on Vercel—super easy since Vercel’s built for Next.js.

8. Push Your Code to GitHub

git init
git add .
git commit -m "Initial nextra docs"
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main

9. Deploy to Vercel

varcel

Customizing Your Nextra Docs Site

Want to make your nextra docs pop? Try these:

I added a custom callout component to my docs—looked pro in 10 minutes!

Troubeshooting and Tips for Nextra Docs

custom nextra documentation example

Why Nextra Docs and Vercel Are a Perfect Pair

Nextra docs makes documentation fun with its Markdown simplicity and Next.js speed. Vercel’s one-click deploys and free hosting seal the deal. Sure, the app router might trip up Next.js newbies, but the Nextra docs are solid. Compared to Docusaurus, nextra docs feels lighter and more modern.

Ready to launch your docs? Build your nextra docs site and deploy to Vercel—I’m stoked to see your creation! And definitely do check out Apidog.

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

Explore more

How to Install and Use Linear MCP Server

How to Install and Use Linear MCP Server

Discover how to install and use Linear MCP to automate Linear tasks with Cursor, Windsurf, and Claude. This tutorial covers setup, authentication, and testing

13 June 2025

Kilo Code, The AI Coding Genius That Outshines Cline & Roo Combined!

Kilo Code, The AI Coding Genius That Outshines Cline & Roo Combined!

Discover Kilo Code, the ultimate AI coding assistant combining Cline and Roo features. Learn how its code generation, task automation, and MCP Server Marketplace revolutionize development.

12 June 2025

What is HeroUI? HeroUI Tutorial for Beginners

What is HeroUI? HeroUI Tutorial for Beginners

💡Want a great API Testing tool that generates beautiful API Documentation? Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity? Apidog delivers all your demands, and replaces Postman at a much more affordable price! button For frontend devs, the demand for aesthetically pleasing, highly performant, and deeply customizable user interfaces has never been greater. Developers are constantly searching for tools that can accelerate their wor

12 June 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs