---
title: "OG images"
description: "Generate link preview images per page with nuxt-og-image, rendered with WebAssembly in the isolate."
canonical_url: "https://docs.lightdrop.cloud/guides/og-images"
---
# OG images

> Generate link preview images per page with nuxt-og-image, rendered with WebAssembly in the isolate.

[nuxt-og-image](https://nuxtseo.com/docs/og-image/getting-started/introduction) renders an
`og:image` for each page from a Vue component. On wervt it renders on request, in the app's isolate.

```bash
pnpm add nuxt-og-image @takumi-rs/core @takumi-rs/wasm
```

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['@wervt/nuxt', 'nuxt-og-image'],
})
```

```vue [pages/index.vue]
<script setup lang="ts">
// components/OgImage/Card.takumi.vue: the image, a component with props
defineOgImage('Card', { title: 'Scoreboard' })
</script>
```

## Why WebAssembly

nuxt-og-image treats the `deno-server` preset like Node and picks its native renderers, which an
isolate can't load: every `/_og/…` image would answer 500. `@wervt/nuxt` switches it to the
WebAssembly builds instead (`ogImage.compatibility.runtime`: `takumi`, `satori` and `resvg` on
`wasm`, no sharp, no browser). An `ogImage.compatibility.runtime` of your own wins over this.

- Install both Takumi packages: `@takumi-rs/wasm` renders, `@takumi-rs/core` is only there because
nuxt-og-image checks for it during the build. For Satori templates (`*.satori.vue`), install
`satori`, `@resvg/resvg-js` and `@resvg/resvg-wasm`. `nuxt build` warns when one is missing.
- Without sharp, images are PNG only, no JPEG.
- Fonts of the templates (from `@nuxt/fonts`, nuxt-og-image 7) work as elsewhere: the build puts
them into `public/`, and `@wervt/nuxt` hands them to the renderer, which can't read `public/`
from inside the isolate. This works in private apps too, as the files come from the runtime
with the app's token instead of through its login.
- Images in a template: a file in `public/` works by path (`/images/logo.png`) or by an absolute
URL on the app's own domain, both served the same way as the fonts. Other URLs are fetched
as they are. A path of the app (`/api/covers/1.jpg`) is loaded in-process. An
[image URL](https://docs.lightdrop.cloud/guides/files#images-resized-on-the-way-out) is answered by wervt before it reaches
the app, so serve it through a route with `fetchImage()`.
- The WebAssembly renderer adds about 5 MB to the server build.

## Private apps

`/_og/…` is a route of the app like any other, so a private app's images need a login, and chats
can't fetch them. For a private app's shared links, use the static image of its
[link preview](https://docs.lightdrop.cloud/guides/private-apps#link-previews) instead.


## Sitemap

See the full [sitemap](https://docs.lightdrop.cloud/sitemap.md) for all pages.
