|
| 1 | +--- |
| 2 | +title: Takumi Renderer |
| 3 | +description: Learn how to use the Takumi renderer for faster OG image generation. |
| 4 | +--- |
| 5 | + |
| 6 | +[Takumi](https://github.com/kane50613/takumi) is an alternative renderer built on Rust that directly rasterizes to PNG/JPEG/WebP without an SVG intermediate step. |
| 7 | + |
| 8 | +It's designed as a faster alternative to [Satori](/docs/og-image/guides/satori) for simple templates, offering 2-10x better performance according to [Takumi benchmarks](https://takumi.kane.tw/docs/). |
| 9 | + |
| 10 | +::code-group |
| 11 | + |
| 12 | +```ts [Set Default] |
| 13 | +export default defineNuxtConfig({ |
| 14 | + ogImage: { |
| 15 | + defaults: { |
| 16 | + renderer: 'takumi' |
| 17 | + } |
| 18 | + } |
| 19 | +}) |
| 20 | +``` |
| 21 | + |
| 22 | +```ts [defineOgImage] |
| 23 | +defineOgImage({ |
| 24 | + renderer: 'takumi' |
| 25 | +}) |
| 26 | +``` |
| 27 | + |
| 28 | +```ts [defineOgImageComponent] |
| 29 | +defineOgImageComponent('MyOgImage', { |
| 30 | + renderer: 'takumi' |
| 31 | +}) |
| 32 | +``` |
| 33 | + |
| 34 | +:: |
| 35 | + |
| 36 | +## Installation |
| 37 | + |
| 38 | +Takumi requires installing the [`@takumi-rs/core`](https://www.npmjs.com/package/@takumi-rs/core) package for Node.js or [`@takumi-rs/wasm`](https://www.npmjs.com/package/@takumi-rs/wasm) for edge runtimes. |
| 39 | + |
| 40 | +::code-group |
| 41 | + |
| 42 | +```sh [pnpm] |
| 43 | +pnpm i -D @takumi-rs/core @takumi-rs/wasm |
| 44 | +``` |
| 45 | + |
| 46 | +```bash [yarn] |
| 47 | +yarn add -D @takumi-rs/core @takumi-rs/wasm |
| 48 | +``` |
| 49 | + |
| 50 | +```bash [npm] |
| 51 | +npm install -D @takumi-rs/core @takumi-rs/wasm |
| 52 | +``` |
| 53 | + |
| 54 | +:: |
| 55 | + |
| 56 | +## Pros |
| 57 | + |
| 58 | +- **2-10x faster** than Satori+Resvg for simple templates |
| 59 | +- Direct PNG/JPEG/WebP rasterization (no SVG intermediate) |
| 60 | +- Native [Tailwind CSS](https://tailwindcss.com/) support via `tw` prop |
| 61 | +- Works on Node.js and edge runtimes (WASM) |
| 62 | +- Variable font support |
| 63 | +- WOFF2 font format support |
| 64 | +- RTL text support |
| 65 | +- COLR emoji font support (e.g., Twemoji) |
| 66 | + |
| 67 | +## Cons |
| 68 | + |
| 69 | +- Limited CSS support compared to [Satori](/docs/og-image/guides/satori) |
| 70 | +- No gradient backgrounds |
| 71 | +- Opacity color syntax not fully supported |
| 72 | +- Some flexbox features missing |
| 73 | + |
| 74 | +## Limitations |
| 75 | + |
| 76 | +Takumi has more CSS limitations than Satori. It works best with simple, solid-color templates. |
| 77 | + |
| 78 | +For the full list of supported CSS properties, see the [Takumi documentation](https://takumi.kane.tw/docs/). |
| 79 | + |
| 80 | +### Supported Features |
| 81 | + |
| 82 | +| Feature | Status | Notes | |
| 83 | +|---------|--------|-------| |
| 84 | +| Solid background colors | ✅ | `bg-gray-900`, `bg-blue-500` | |
| 85 | +| Basic flexbox | ✅ | `flex`, `items-center`, `justify-center` | |
| 86 | +| Text colors (solid) | ✅ | `text-white`, `text-gray-500` | |
| 87 | +| Font sizes and weights | ✅ | `text-6xl`, `font-bold` | |
| 88 | +| Rounded corners | ✅ | `rounded-lg`, `rounded-full` | |
| 89 | +| Emoji | ✅ | Via COLR fonts | |
| 90 | +| Images | ✅ | PNG, JPEG, WebP, SVG | |
| 91 | +| Padding and margin | ✅ | `p-4`, `m-2`, `gap-4` | |
| 92 | +| Width and height | ✅ | `w-full`, `h-16`, `w-[200px]` | |
| 93 | + |
| 94 | +### Unsupported Features |
| 95 | + |
| 96 | +| Feature | Status | Alternative | |
| 97 | +|---------|--------|-------------| |
| 98 | +| Gradient backgrounds | ❌ | Use solid colors or images | |
| 99 | +| Opacity colors (`/60`) | ❌ | Use full opacity colors | |
| 100 | +| `justify-between` | ❌ | Use explicit gaps or padding | |
| 101 | +| `flex-1`, `flex-grow` | ❌ | Use fixed widths | |
| 102 | +| CSS transforms | ❌ | Pre-transform images | |
| 103 | +| Box shadows | ❌ | Use border or images | |
| 104 | + |
| 105 | +::tip |
| 106 | +You can try Takumi in the [online playground](https://takumi.kane.tw/docs/) without any installation. |
| 107 | +:: |
| 108 | + |
| 109 | +::warning |
| 110 | +For complex templates with gradients, shadows, or opacity, use the [Satori renderer](/docs/og-image/guides/satori) or [Chromium renderer](/docs/og-image/guides/chromium) instead. |
| 111 | +:: |
| 112 | + |
| 113 | +## When to Use Takumi |
| 114 | + |
| 115 | +Takumi is ideal for: |
| 116 | +- Simple templates with solid colors |
| 117 | +- High-throughput scenarios where speed matters |
| 118 | +- Edge runtime deployments where bundle size is important |
| 119 | +- Sites with many pages that need fast OG image generation |
| 120 | + |
| 121 | +Consider [Satori](/docs/og-image/guides/satori) instead when: |
| 122 | +- You need gradient backgrounds |
| 123 | +- You need opacity/transparency effects |
| 124 | +- You need complex flexbox layouts |
| 125 | + |
| 126 | +Consider [Chromium](/docs/og-image/guides/chromium) instead when: |
| 127 | +- You need full CSS support |
| 128 | +- You're prerendering all images at build time |
| 129 | + |
| 130 | +## Example Template |
| 131 | + |
| 132 | +A Takumi-compatible template using only supported features: |
| 133 | + |
| 134 | +```vue |
| 135 | +<script setup lang="ts"> |
| 136 | +defineProps<{ |
| 137 | + title: string |
| 138 | + description?: string |
| 139 | +}>() |
| 140 | +</script> |
| 141 | +
|
| 142 | +<template> |
| 143 | + <div class="w-full h-full flex flex-col items-center justify-center bg-gray-900 text-white p-12"> |
| 144 | + <h1 class="text-6xl font-bold mb-4"> |
| 145 | + {{ title }} |
| 146 | + </h1> |
| 147 | + <p v-if="description" class="text-2xl text-gray-400"> |
| 148 | + {{ description }} |
| 149 | + </p> |
| 150 | + </div> |
| 151 | +</template> |
| 152 | +``` |
| 153 | + |
| 154 | +## Runtime Compatibility |
| 155 | + |
| 156 | +Takumi supports both Node.js and WASM runtimes. The module automatically selects the appropriate binding based on your deployment target. |
| 157 | + |
| 158 | +| Environment | Binding | Notes | |
| 159 | +|-------------|---------|-------| |
| 160 | +| Node.js | `@takumi-rs/core` | Native performance | |
| 161 | +| Cloudflare Workers | `@takumi-rs/wasm` | WASM bundle | |
| 162 | +| Vercel Edge | `@takumi-rs/wasm` | WASM bundle | |
| 163 | +| Netlify Edge | `@takumi-rs/wasm` | WASM bundle | |
| 164 | +| AWS Lambda | `@takumi-rs/core` | Native performance | |
| 165 | + |
| 166 | +See the [Compatibility guide](/docs/og-image/guides/compatibility) for more details on runtime support. |
| 167 | + |
| 168 | +## Disabling Takumi |
| 169 | + |
| 170 | +If you have Takumi installed but want to disable it for specific environments: |
| 171 | + |
| 172 | +```ts [nuxt.config.ts] |
| 173 | +export default defineNuxtConfig({ |
| 174 | + ogImage: { |
| 175 | + compatibility: { |
| 176 | + runtime: { |
| 177 | + takumi: false |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | +}) |
| 182 | +``` |
0 commit comments