Generate or choose an image, deploy it at a publicly accessible HTTPS address, then put that absolute address in the page’s og:image metadata. The address may point to a static file or to a route that renders an image when a crawler requests it. In Next.js, you can use the opengraph-image file convention or create a dynamic route with ImageResponse.
What an Open Graph image URL needs to do
An Open Graph image URL is the value of the content attribute in a page’s <meta property="og:image"> tag. It tells a social platform where to fetch the image associated with that page. The URL must be absolute, such as https://example.com/images/article.png, rather than a relative path such as /images/article.png. Next.js metadata examples use absolute image URLs, and Vercel’s example uses a deployed endpoint in the same way: https://og-examples.vercel.sh/api/static.
The URL does not need to end in a familiar image filename if it is a route that responds with an image. A generated endpoint can use page-specific query parameters, for example https://example.com/api/og?title=Example. In either case, the deployed URL must be reachable by the social crawler without a login, and its response must be the intended image.
For a conventional landscape share image, Vercel recommends a canvas of 1200 × 630 pixels. Treat this as a documented recommendation, not a guarantee that every platform displays images identically: platforms can crop or render previews differently.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems#1 Best Overall
Choose static or generated images
| Approach | Best fit | What to plan for |
|---|---|---|
| Static image file | A site-wide or route-specific image that changes only when you update the asset. | Put the file in the right route segment and let the framework publish its metadata. |
| Generated image file convention | Images created from route data inside a Next.js app, such as a blog post slug. | Next.js generates the image; static optimization and caching apply by default unless Dynamic APIs or uncached data make the route dynamic. |
| Parameterized image endpoint | A reusable template that renders titles or other page-specific values on request. | Validate and constrain inputs, make crawler access public, and decide how caching and updates should work. |
Use a static file when the image is effectively an asset. Use a generated route when page data should shape the image. A parameterized endpoint is useful when you want one template to serve many URLs, but it adds input handling and cache-invalidation decisions.
Use a static Open Graph image in Next.js
For a static image, place a supported image file in the route segment it represents. For example, an image intended for the home route can live at app/opengraph-image.jpg; an image specific to a blog route can live in that route’s segment. Next.js recognizes opengraph-image.jpg, .jpeg, .png, and .gif and adds the corresponding metadata. A more specific route-segment image takes precedence over one higher in the folder tree.
- Add the asset: put
opengraph-image.jpgin the relevantapproute segment. - Deploy the application: use the deployed route, not a local development address.
- Inspect the page metadata: open the deployed page source or inspect its document head and confirm that Next.js emitted an absolute HTTPS
og:imagevalue. - Open the image URL directly: confirm it returns the intended image to an unauthenticated visitor.
This convention avoids writing a metadata URL by hand for that image. It is not the right choice if every page needs its own data-driven design; use a generated image or endpoint for that.
Rank #2
Generate one image per route with the Next.js file convention
Create a file such as app/blog/[slug]/opengraph-image.tsx. Its default export returns an ImageResponse from next/og. Next.js supports route parameters, so the slug can provide page-specific text. The following illustrative pattern draws a title from the slug:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallimport { ImageResponse } from 'next/og'
export const size = { width: 1200, height: 630 }
export const contentType = 'image/png'
export default async function Image({ params }: { params: { slug: string } }) {
return new ImageResponse(
<div style={{ display: 'flex', fontSize: 64 }}>
{params.slug}
</div>,
size,
)
}
Use your actual page data instead of a raw slug when you need a readable headline. Keep the result legible at the final image size: long titles may need a smaller font, line limits, or a deliberate layout. The image route and its metadata are tied to the route segment, so check the deployed page rather than assuming the file’s presence proves the final URL is correct.
Next.js generated image routes are statically optimized and cached by default unless Dynamic APIs or uncached data are used. That behavior is useful when the title is stable, but it matters when content can change: decide whether a newly edited title should regenerate or invalidate the image and any downstream CDN or social-platform copy.
Build a reusable parameterized image endpoint
A route handler can read values from the request URL, render an image, and return it. This example caps the title at 100 characters and supplies a fallback when the parameter is absent. It uses basic JSX/CSS supported by the documented image renderer:
import { ImageResponse } from 'next/og'
export async function GET(request: Request) {
const { searchParams } = new URL(request.url)
const title = searchParams.get('title')?.slice(0, 100) ?? 'Default title'
return new ImageResponse(
<div style={{ display: 'flex', fontSize: 64 }}>{title}</div>,
{ width: 1200, height: 630 },
)
}
Deploy this handler at a route such as /api/og. Then add an absolute URL to the page head, encoding query values when constructing the URL:
Recommended Free Tools
<meta property="og:image" content="https://example.com/api/og?title=Example" />
In application code, generate the query string with a URL or URL-encoding utility rather than concatenating untrusted text into a URL. Also treat query parameters as input, not trusted markup: constrain length and accepted data, and do not interpret user-provided content as code. If the route uses page data that changes, choose a cache strategy that allows the preview to catch up with the page.
Rank #4
Rendering limits that affect the result
Next.js and Vercel’s documented OG approach converts supported HTML and CSS into PNG using Satori and Resvg. Flexbox is supported, but CSS Grid and other unsupported properties should not be assumed to work. Build the layout from supported primitives and inspect the actual generated image instead of relying on how a normal browser renders the same markup.
- Fonts: Vercel documents
ttf,otf, andwofffont formats for this setup. Include and load only what the image needs. - Bundle size: the documented Vercel setup has a 500 KB maximum bundle, including JSX, CSS, fonts, and images. Large embedded assets can exceed the limit.
- Runtime: the documented Vercel setup requires Node.js 22 or newer and supports the Node.js runtime. Check the requirements for the deployment environment you use.
- External resources: if the image depends on fonts or assets, verify that they are available to the renderer in production; a successful local page render does not establish that every dependency works in the image route.
- Robots access: Vercel recommends allowing the OG API route in
robots.txtso social providers can fetch it. Confirm your deployment’s crawler policy does not block the route.
These are constraints of the documented Vercel rendering setup, not universal requirements for every possible image service or framework.
Validate the deployed metadata and image
- Check the page head: inspect deployed HTML or the browser’s document head. Confirm
og:imageis present and contains the intended absolute HTTPS URL. - Request the image URL directly: open it in a private browser window or make an unauthenticated request. It should return an image, not a sign-in page, HTML error, or redirect to a private resource.
- Check crawler access: verify the route is permitted by the site’s robots policy and any access controls.
- Inspect the rendered output: view it at 1200 × 630 and check text wrapping, contrast, fonts, and assets. Test the longest realistic title, not only a short example.
- Use a preview inspector: Vercel documents an Open Graph preview workflow in its Next.js documentation. Use the relevant platform or hosting preview before publishing.
- Retest after changes: static and CDN caching can preserve a previous image. Use a deliberate invalidation or versioning strategy when templates or title data change.
Troubleshoot common failures
The social preview has no image
- Check that the deployed page contains
og:image, not only that your source file appears to define it. - Replace a relative value with an absolute HTTPS URL.
- Open the image URL without authentication. Fix access controls, broken deployments, or crawler blocks if the request cannot retrieve the image.
- Check the rendered response and robots policy; a correct-looking page in a logged-in browser does not prove that a social crawler can fetch the image.
The image route returns an error or unexpected HTML
- Request the route directly and inspect the response. Confirm the path, handler, and deployed build are correct.
- For a parameterized route, test with no title, an ordinary title, and a long or encoded title. Keep a fallback and constrain input length.
- For the documented Vercel setup, check its Node.js requirement, the 500 KB bundle limit, and whether every CSS property and font format is supported.
The output looks wrong compared with the page
- Do not assume ordinary browser CSS support. Replace unsupported layout properties such as CSS Grid with supported approaches such as Flexbox.
- Check font loading and title wrapping in the generated image itself. Adjust the renderer markup for long text rather than expecting the crawler to resize it.
- Confirm external assets are available to the renderer at request time and are not blocked or private.
A changed title still shows the old image
Generated routes may be static or cached, and Vercel adds CDN caching headers for computed images. Review whether the route is using static data or dynamic behavior, then use a deliberate cache invalidation or versioned URL strategy. A query parameter can distinguish versions, but only if the caching layer treats it as part of the cache key.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Best Value
Or skip the browser setup
If you want to inspect the deployed page’s screenshot while checking an OG implementation, ScreenshotNeo can capture the page from one GET request. The returned screenshot is useful for checking the page itself; it does not replace testing the generated image URL or the social platform’s preview. See the ScreenshotNeo website and API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots. Sign up for 1,000 free screenshots a month with no card.
Make caching and updates intentional
An image URL can remain unchanged while its generated bytes change, which makes caching important. Next.js generated image conventions are cached or statically optimized by default unless Dynamic APIs or uncached data opt the route into dynamic behavior; Vercel also documents CDN caching headers for computed images. If the image is based on a title that can be edited, determine how updates reach the image route and how cached copies are invalidated. A versioned URL is one possible way to request a distinct resource after a meaningful template change, but it is only effective if the version participates in the cache key.
For parameterized endpoints, avoid putting highly volatile or unbounded content into query strings without considering the number of distinct URLs and the relevant cache behavior. Keep query values short, encode them correctly, and make the output deterministic for a given input where practical. That makes rendered results easier to test and reduces ambiguity when debugging a stale or incorrect preview.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Frequently Asked Questions
Does the `og:image` URL have to use the same domain as the page?
The cited documentation establishes that the value must be an absolute URL; it does not establish a same-domain requirement. Whatever host you use must serve the intended image publicly to the crawler.
Can I use a URL with a query string as the Open Graph image?
Yes. A generated endpoint can carry page-specific values in URL parameters, provided the endpoint returns an image and the URL is properly encoded.
Does generating an image guarantee every social platform will display it the same way?
No. The 1200 × 630 size is a documented recommendation, not a guarantee of identical rendering or cropping across platforms.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




