Static Build
Output static website with Fumadocs.
Setup
By default, Fumadocs uses a server-first approach, which requires a running server. You can output a static build by configuring React Router.
Search
Built-in Search
After the configurations, your app will statically store the search indexes, and search will be computed on browser instead.
Cloud Solutions
Since the search functionality is powered by remote servers, static export works without configuration.
Deployment
With SPA mode, you can serve the build/client directory as a static website.
Don't forget to pre-render
On SPA mode, all your server-side loaders must be pre-rendered.
See React Router Docs for details.
import type { Config } from '@react-router/dev/config';
import { glob } from 'node:fs/promises';
import { createGetUrl, getSlugs } from 'fumadocs-core/source';
const getUrl = createGetUrl('/docs');
export default {
// disable SSR
ssr: false,
async prerender({ getStaticPaths }) {
const paths: string[] = [...getStaticPaths()];
for await (const entry of glob('**/*.mdx', { cwd: 'content/docs' })) {
paths.push(getUrl(getSlugs(entry)));
}
return paths;
},
} satisfies Config;How is this guide?
Last updated on
