First you have to install the dependencies
1npm install dokz @emotion/core @chakra-ui/core emotion-theming @emotion/styled2# or3yarn add dokz @emotion/core @chakra-ui/core emotion-theming @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'45export default function App(props) {6const { Component, pageProps } = props7const { pathname } = useRouter()8if (pathname.startsWith('/docs')) {9return (10<DokzProvider docsRootPath='pages/docs'>11<Component {...pageProps} />12</DokzProvider>13)14}15return <Component {...pageProps} />16}
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