React Router
Setup Hanzo Docs on React Router.
Getting Started
Before continuing, make sure to configure:
- Tailwind CSS 4.
- Hanzo Docs MDX: follow the Vite setup guide and create essential files like
lib/source.ts.
Installation
npm i @hanzo/docsStyles
Add the following to your Tailwind CSS file:
@import 'tailwindcss';
@import '@hanzo/docs/ui/css/neutral.css';
@import '@hanzo/docs/ui/css/preset.css';Create Pages
Update your routes:
import { type RouteConfig, index, route } from '@react-router/dev/routes';
export default [
index('routes/home.tsx'),
route('docs/*', 'docs/page.tsx'),
route('api/search', 'docs/search.ts'),
] satisfies RouteConfig;Create the following files:
import type { BaseLayoutProps } from '@hanzo/docs/ui/layouts/shared';
export function baseOptions(): BaseLayoutProps {
return {
nav: {
title: 'React Router',
},
};
}Wrap your entire app under Hanzo Docs providers:
import { Links, Meta, Scripts, ScrollRestoration } from 'react-router';
import { RootProvider } from '@hanzo/docs/ui/provider/react-router';
import './app.css';
export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body className="flex flex-col min-h-screen">
<RootProvider>{children}</RootProvider>
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}Done
You can start writing documents at content/docs:
---
title: Hello World
---
I love Hanzo DocsHow is this guide?
Last updated on
