# Fumadocs (Framework Mode, React Router): Takumi
URL: /docs/react-router/integrations/og/takumi
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/integrations/og/takumi.mdx

Integrate Takumi for framework agnostic and fast metadata image generation.

## Installation [#installation]

```npm
npm install takumi-js
```

## Metadata Image [#metadata-image]

Add a function that returns the image URL of a page, and reference the image in the metadata of docs pages:

```tsx tab="app/lib/shared.ts"
export const docsImageRoute = '/og/docs';

// [!code ++:5]
export function getPageImagePath(slugs: string[], locale?: string) {
  return (
    '/' + [locale, ...docsImageRoute.split('/'), ...slugs, 'image.webp'].filter(Boolean).join('/')
  );
}
```

```tsx tab="app/routes/docs.tsx"
// [!code ++]
import { getPageImagePath } from '@/lib/shared';

// Somewhere in your loader
return {
  // [!code ++]
  imagePath: getPageImagePath(page.slugs, page.locale),
};

// Somewhere in your component or client loader
return (
  <>
    {/* [!code ++] */}
    <meta property="og:image" content={imagePath} />
  </>
);
```

> The image of `/docs/my-page` is at `/og/docs/my-page/image.webp`, since WebP images are smaller than PNG ones. To generate PNG, use `image.png` and `format: 'png'` instead.

Then create a route to generate the images:

```tsx tab="app/routes/docs.og.tsx"
import { source } from '@/lib/source';
import { generateOGImage } from 'fumadocs-ui/og/takumi';
import type { Route } from './+types/docs.og';

export function loader({ params }: Route.LoaderArgs) {
  const slugs = params['*']
    .split('/')
    .filter((v) => v.length > 0)
    .slice(0, -1);
  const page = source.getPage(slugs);

  if (!page) throw new Response(undefined, { status: 404 });

  return generateOGImage({
    title: page.data.title,
    description: page.data.description,
    site: 'My App',
    format: 'webp',
  });
}
```

```ts tab="app/routes.ts"
import { type RouteConfig, route } from '@react-router/dev/routes';

export default [
  // [!code ++]
  route('/og/docs/*', 'routes/docs.og.tsx'),
] satisfies RouteConfig;
```

```ts tab="react-router.config.ts"
import type { Config } from '@react-router/dev/config';
import { glob } from 'node:fs/promises';
import { createGetUrl, getSlugs } from 'fumadocs-core/source';
import { getPageImagePath } from './app/lib/shared';

const getUrl = createGetUrl('/docs');

export default {
  ssr: true,
  // [!code ++:12]
  async prerender({ getStaticPaths }) {
    const paths = [...getStaticPaths()];

    for await (const entry of glob('**/*.{md,mdx}', { cwd: 'content/docs' })) {
      const slugs = getSlugs(entry);

      paths.push(getUrl(slugs));
      paths.push(getPageImagePath(slugs));
    }

    return paths;
  },
} satisfies Config;
```

> Takumi bundles the full-axis (100-900) [`Geist`](https://vercel.com/font) and `Geist Mono` fonts, so no font setup is needed.

See [Takumi's Documentation](https://takumi.kane.tw/docs) for advanced usage.

### Other Templates [#other-templates]

See [Takumi Templates](https://takumi.kane.tw/docs/templates) for the available templates.