First you have to install the dependencies
1npm install dokz @emotion/react @chakra-ui/react @emotion/styled2# or3yarn add dokz @emotion/react @chakra-ui/react @emotion/styled
Add the dokz provider to the main nextjs _app.jsx
component
In this example i am also using docsRootPath='pages/docs'
to hide other pages outside of the docs
directories in the side nav
Remember that the only children of DokzProvider
must be the nextjs App
props.Component
!
1// _app.jsx2import { DokzProvider } from 'dokz'3import { useRouter } from 'next/router'4import { ChakraProvider } from '@chakra-ui/react'56export default function App(props) {7const { Component, pageProps } = props8const { pathname } = useRouter()9if (pathname.startsWith('/docs')) {10return (11<ChakraProvider resetCSS>12<DokzProvider docsRootPath='pages/docs'>13<Component {...pageProps} />14</DokzProvider>15</ChakraProvider>16)17}18return <Component {...pageProps} />19}
Add withDokz
in the next.config.js
file
1const { withDokz } = require('dokz/dist/plugin')23module.exports = withDokz()
Now you can add MDX documents in the pages/docs
directory and live preview them at http://localhost:3000/docs