Docs Theme

Quick Start from Template

Deploy to Vercel

Fork the Template

(todo)

Start from Empty Project

Install

To create a Nextra Docs site manually, you have to install Next.js, React, Nextra, and Nextra Docs Theme. In your project directory, run the following command to install the dependencies:

pnpm i next react react-dom nextra nextra-theme-docs

Like any Next.js projects, you need to also add scripts to your package.json:

package.json
{
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start"
  }
}

If you already have Next.js running, you only need to install nextra and nextra-theme-docs as the add-ons.

Create Nextra Config

Create the following next.config.js file in your project’s root directory:

next.config.js
const withNextra = require('nextra')({
  theme: 'nextra-theme-docs',
  themeConfig: './theme.config.jsx',
})
 
module.exports = withNextra()
// or module.exports = withNextra({ /* other next.js config */ })

Here you can configure Nextra to propoerly handle your Markdown files. With the above configurations, Nextra will first compile the content to JSX, and then render the site with configured theme.

Full Nextra configurations can be found here:

Create Docs Theme Config

Lastly, create the corresponding theme.config.jsx file in your project’s root directory:

theme.config.jsx
export default {
  logo: <span>My Nextra Documentation</span>,
  // ...
}

More configuration options for the docs theme can be found here:

Ready to Go!

Now, you can create an initial MDX page:

pages/index.mdx
# Welcome to Nextra
 
Hello, world!

And run the dev command to start developing the project:

pnpm dev