🚧 This is a work-in-progress docs for Nextra 2.0, content may be incomplete or inaccurate.
Documentation
Get Started

Docs Theme

💡

If you need an example, this website itself is built with the docs theme.

Quick Start from Template

Deploy to Vercel

Fork the Template

(todo)

Start from Empty Project

1. 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
npm i next react react-dom nextra nextra-theme-docs
yarn add next react react-dom nextra nextra-theme-docs

Like any Next.js projects, you need to also add scripts to your 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.

2. Create Next.js Config

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

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:

3. Create Docs Theme Config

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

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

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

4. Start Project

Now, you can create an initial Markdown page (pages/index.mdx) in your project’s root directory:

# Welcome to Nextra
 
Hello, world!

And run the following command to start the project:

pnpm dev
Last updated on August 21, 2022