import { Callout, Tab, Tabs } from 'nextra-theme-docs'
{/* You can start by creating your own Nextra site and deploying to Vercel by clicking the link: */}
{/* Vercel will fork the Nextra Docs template and deploy the site for you. Once done, every commit in the repository will be deployed automatically. */}
(todo)
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:
<Tabs items={['pnpm', 'npm', 'yarn']}>
bash pnpm i next react react-dom nextra nextra-theme-docs
bash npm i next react react-dom nextra nextra-theme-docs
bash 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.
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.
import { Card, Cards } from '@components/card'
Full Nextra configurations can be found here:
import switchIcon from '@components/icons/switch'
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:
Now, you can create an initial MDX page:
# Welcome to Nextra
Hello, world!
And run the dev
command to start developing the project:
pnpm dev