OG Images in Remix and React Router v7
If you searched for "Remix OG image", the first thing to know is where Remix went. In May 2024 the Remix team announced that what was planned as Remix v3 would ship as React Router v7 instead, and since December 2024 they recommend starting new projects with React Router v7 and upgrading existing Remix apps. Remix v2 apps still work. The upgrade is mostly changing @remix-run/* imports to react-router. React Router has since moved on to v8 (the docs list 8.5 as latest on 21 Oct 2026). Everything here applies to v7 and v8 unless noted.
This guide uses React Router's framework mode (the Remix successor) and notes where Remix v2 differs. It covers the meta export, building absolute image URLs from a loader, generating images yourself in a resource route, and the alternative: one Unfurlkit URL per page.
Sources checked (21 Oct 2026): Remix blog, "Merging Remix and React Router" with its Dec 2024 update (https://remix.run/blog/merging-remix-and-react-router). React Router docs: Route Module (https://reactrouter.com/start/framework/route-module) Upgrading from v7 (https://reactrouter.com/upgrading/v7), which documents the
metadata→loaderDatachange, Resource Routes (https://reactrouter.com/how-to/resource-routes) and File Route Conventions (https://reactrouter.com/how-to/file-route-conventions).
Version check: data vs loaderData
The meta function's arguments changed over time:
- Remix v2:
meta({ data }). - React Router v7:
loaderDatawas added alongsidedata, anddatawas deprecated. - React Router v8:
datawas removed. UseloaderData.
The examples below use loaderData. If you're still on Remix v2, read data instead.
Step 1: The meta export
In framework mode, a route module can export meta, returning an array of tag descriptors. Your root renders them with <Meta />:
// app/routes/blog.$slug.tsx
import type { Route } from './+types/blog.$slug';
export async function loader({ params }: Route.LoaderArgs) {
const post = await getPost(params.slug); // your data source
if (!post) throw new Response('Not found', { status: 404 });
return { post };
}
export function meta({ loaderData }: Route.MetaArgs) {
const post = loaderData?.post;
return [
{ title: post?.title },
{ name: 'description', content: post?.description },
{ property: 'og:title', content: post?.title },
{ property: 'og:description', content: post?.description },
{ property: 'og:image', content: post?.image }, // absolute URL
{ name: 'twitter:card', content: 'summary_large_image' },
];
}
// app/root.tsx (excerpt)
import { Meta, Links } from 'react-router';
export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<Meta />
<Links />
</head>
<body>{children}</body>
</html>
);
}
Two behaviors from the docs that trip people up:
- The last matching route's meta wins, and it replaces the whole array. Child meta isn't merged with the parent's. If a layout sets
og:site_nameand a child route exportsmeta, the child must include it again (you can read parent data frommatches). - React 19
<meta>elements are now recommended over themetaexport. You can render<title>and<meta property="og:image" ...>directly in your component, and React hoists them into the head. Both approaches render server-side, which is what crawlers need.
Absolute URLs from the loader
og:image should be an absolute https:// URL. The loader receives the request, so derive the origin there instead of hard-coding it:
export async function loader({ params, request }: Route.LoaderArgs) {
const post = await getPost(params.slug);
if (!post) throw new Response('Not found', { status: 404 });
const origin = new URL(request.url).origin;
return { post, image: `${origin}/og/${params.slug}.png` };
}
Behind a proxy, request.url may show an internal host. In that case use a configured site URL from the environment.
Step 2 (DIY): Generate images in a resource route
A route module that exports a loader but no default component is a resource route. It can return any Response, including a PNG. The common pattern is Satori (HTML/JSX to SVG) plus a PNG converter such as @resvg/resvg-js:
// app/routes/og.$slug[.png].tsx
import satori from 'satori';
import { Resvg } from '@resvg/resvg-js';
import { readFile } from 'node:fs/promises';
import type { Route } from './+types/og.$slug[.png]';
const font = readFile('./fonts/Inter-Bold.ttf'); // TTF/OTF/WOFF, not WOFF2
export async function loader({ params }: Route.LoaderArgs) {
const post = await getPost(params.slug);
const title = post?.title || 'My Blog';
const svg = await satori(
<div style={{ display: 'flex', width: '100%', height: '100%', padding: 80,
background: '#111', color: '#fff', fontSize: 64 }}>
{title}
</div>,
{ width: 1200, height: 630, fonts: [{ name: 'Inter', data: await font, weight: 700 }] },
);
const png = new Resvg(svg).render().asPng();
return new Response(png, {
headers: {
'Content-Type': 'image/png',
'Cache-Control': 'public, max-age=86400, s-maxage=31536000, immutable',
},
});
}
This file needs JSX, so use .tsx. The file name uses the file-route conventions (@react-router/fs-routes), where [.png] escapes the dot so the URL ends in .png. The docs' own example is reports.$id[.pdf].ts. If you configure routes in routes.ts instead, register the path there. Satori and resvg behaviors come from their own docs, so check them for your versions.
The trade-offs
- Rendering runs on your server. Every uncached request costs CPU. Satori is flexbox-only with a CSS subset.
- Fonts are on you. Load them explicitly. WOFF2 isn't supported by Satori.
- Caching is on you. Without long-lived CDN headers and versioned URLs, crawlers trigger re-renders.
- Native or WASM dependencies.
@resvg/resvg-jsships native binaries, and edge runtimes need WASM variants. - Abuse. If your route accepts free text in the query string, anyone can render images on your server. Look content up by slug, as above, rather than trusting query text.
Step 2 (alternative): One URL with Unfurlkit
Skip the resource route and return a hosted URL from the loader:
// app/routes/blog.$slug.tsx
const ogUrl = (title: string) =>
'https://unfurlkit.com/v1/basic.png?' +
new URLSearchParams({ title: title || 'My Blog', theme: 'dark' }).toString();
export async function loader({ params }: Route.LoaderArgs) {
const post = await getPost(params.slug);
if (!post) throw new Response('Not found', { status: 404 });
return { post, image: ogUrl(post.title) };
}
export function meta({ loaderData }: Route.MetaArgs) {
return [
{ title: loaderData?.post.title },
{ property: 'og:title', content: loaderData?.post.title },
{ property: 'og:image', content: loaderData?.image },
{ property: 'og:image:width', content: '1200' },
{ property: 'og:image:height', content: '630' },
{ name: 'twitter:card', content: 'summary_large_image' },
];
}
title is required and must be non-empty. The basic template also takes subtitle, theme (light or dark) and accent (6-digit hex, no #). See the basic template.
Plans. Every image URL needs your key. A Free key gets 10 renders in total (no monthly reset), with a small "unfurlkit" watermark, and needs no card. Pro is $9/mo or $90/yr, with 10,000 renders a month, no watermark, and custom fonts (Inter, Roboto, Playfair Display, JetBrains Mono) and logo. Pro URLs add your public key k and a signature s.
Signing. Loaders run on the server (or at build time when prerendering), so they're the right place to sign. Read the secret from process.env in the loader, and never in a clientLoader or component code:
import { signedOgUrl } from '~/lib/unfurlkit.server'; // the Node snippet from our signing guide
export async function loader({ params }: Route.LoaderArgs) {
const post = await getPost(params.slug);
if (!post) throw new Response('Not found', { status: 404 });
const image = signedOgUrl(
{ title: post.title || 'My Blog', theme: 'dark' },
process.env.UNFURLKIT_PUBLIC_KEY!,
process.env.UNFURLKIT_SECRET_KEY!,
);
return { post, image };
}
The .server suffix keeps the module out of client bundles. See Signing Pro URLs.
A render is counted only when a unique image is generated and wasn't already cached. Shares and cache hits don't count. Over the limit, images keep rendering. On a signed Free key, images already made keep showing, and new ones get a plain version (your title on the basic card, with the small mark) that doesn't count. Upgrade to Pro for more renders. On Pro there's no hard stop and no overage charge, and we may contact you about your usage. Upgrade to Pro to remove watermarks from all your images. See pricing.
Which option should you use?
| Situation | Best fit |
|---|---|
| A static marketing site with a few pages | A static image in public/ |
| Custom-designed cards, and you're happy to run rendering and caching | Resource route with Satori |
| No rendering in your app, a clean standard card | Unfurlkit |
| You need right-to-left scripts today | Resource route with suitable fonts (Unfurlkit doesn't support RTL yet) |
Debugging checklist
- View the page source and search for
og:image. If it's missing, check that<Meta />is in your root<head>and that a deeper route'smetaisn't replacing it. - SPA mode? With
ssr: falseand no prerendering, crawlers get an HTML shell without your tags. Prerender or server-render shareable routes. - Image URL absolute? Open it on its own. It must return an image, not HTML.
- Resource route returning HTML? Make sure the module has no default export, and that the
Content-Typeisimage/png. - Unfurlkit 400? Missing or empty
title, or an invalid param. - Run the Free OG Image Checker to preview X, LinkedIn, Facebook, WhatsApp, Slack, Discord and iMessage.
See also OG image not showing.
FAQ
Which languages and scripts are supported? Right-to-left scripts such as Arabic and Hebrew aren't supported yet at launch.
Is Remix dead? No. The Remix team now develops React Router as its framework, and says the Remix brand continues. For new projects they recommend React Router v7. This guide's patterns apply to both.
meta export or <meta> in the component?
The docs now recommend React 19's built-in <meta> elements. The meta export still works and is useful when you want the parent/child replacement rules.
Can I use other Satori-based libraries here? Generic libraries built on Satori work in a resource route, subject to your runtime. Check the library's docs for supported platforms.
What size should the image be? 1200×630. See OG image size.
Summary
Put tags in meta (or React 19 <meta>), build absolute URLs in the loader, and decide who renders the image. A resource route gives full control and full responsibility. An Unfurlkit URL is one line in your loader.
See Unfurlkit pricing · Check any page with the Free OG Image Checker.