Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To test a Next.js Open Graph image locally, run the app, inspect the page’s generated og:image tag, then open or request the image URL it names. That verifies your local page metadata and image route. It does not show whether a social platform can fetch the image: for that, test a publicly reachable preview deployment with the platform you care about.

What a localhost test can—and cannot—prove

A local test is useful for finding missing metadata, a wrong image URL, a broken generated-image route, or an image that does not look as expected. Next.js Metadata APIs produce the relevant tags in the document head, which you can inspect in browser developer tools. The result verifies what your local app serves to your browser; it does not establish what a remote social crawler will receive. A crawler cannot reach your development machine through its own localhost address. Next.js also documents that metadata may be streamed for some requests, while HTML-limited crawlers receive blocking metadata behavior. When crawler rendering matters, check the publicly accessible preview as well. Next.js Metadata and OG images · Next.js generateMetadata · Vercel’s OG image guide

Identify which image implementation you are testing

Static image convention

In the App Router, Next.js recognizes files such as opengraph-image.jpg, opengraph-image.png, and supported JPEG, PNG, or GIF variants in a route segment. The convention adds image metadata automatically. A more specific image file deeper in the route tree takes precedence over an ancestor segment’s image, so check the segment that actually owns the route you are viewing.

Generated image convention

A segment can instead contain an opengraph-image.js, .ts, or .tsx file that returns an image response. ImageResponse from next/og is the documented convenient generator. The file can export alt, size, and contentType; Next.js uses these to populate corresponding metadata. In Next.js 16, dynamic route image handlers receive params as a promise, so await it before reading dynamic values. See the Open Graph image file convention reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Useful image constraints

The Next.js reference gives 1200 × 630 pixels as an example size, not a universal promise about every social platform’s requirements. It documents an 8 MB maximum for an opengraph-image file and, separately, a 5 MB maximum for a twitter-image file. Treat those as Next.js convention limits; a platform may have its own card behavior or requirements.

Test the metadata and image route in your local browser

  1. Start the development server. From your project, run your usual development command, commonly npm run dev, and wait for Next.js to report that the server is ready. Open the exact route you want to test, for example http://localhost:3000/ for the home page or a local route such as http://localhost:3000/products/item.
  2. Inspect the rendered document head. Open the browser’s developer tools, select the Elements or Inspector panel, and find the page’s <head>. Look for <meta property="og:image" ...>. Confirm that there is a tag and that its content value identifies the image you intended for this page. Also inspect og:image:alt, width, height, or type tags if your implementation emits them.
  3. Resolve and open the actual image URL. Copy the complete value from og:image, not a guessed route. Open it in another tab. If it is a relative URL, resolve it against the page’s origin first. The browser should show the image rather than an HTML error page or a server error.
  4. Check the image itself. Confirm the image shows the expected page-specific text and artwork, is not clipped, and has the intended proportions. If you export alt, compare the text in og:image:alt with the image content and your intended description.
  5. Repeat on routes with different metadata. Visit representative nested routes, especially ones that use their own metadata image or dynamic data. A passing home page does not prove a nested page selects the right segment’s image.

For an image generator, opening the resolved image URL directly exercises the generated route rather than merely showing that a tag exists. Vercel’s guide illustrates browsing a local generated-image endpoint such as http://localhost:3000/api/og; your route may use a different URL, so trust the URL emitted by your page. Vercel’s OG image guide

Inspect the local result with commands

You can also request the page HTML and search it for the tag. This command is for a shell with curl installed:

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
curl -sS http://localhost:3000/ | grep -i 'og:image'

Change the route to the page you are testing. If no matching output appears, use the browser Elements panel too: metadata can be streamed for some requests, and a plain command-line response may not reflect the same rendering path as a particular crawler. To test the image, use the exact URL you copied from the page’s tag. For example, if the emitted URL is http://localhost:3000/api/og, request that URL directly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -i http://localhost:3000/api/og

Check that the response succeeds and has an image content type, rather than assuming every successful HTTP response is a usable image. Replace the example endpoint with the actual og:image URL from your app. If the URL is relative, include the local origin when making the request.

Debug a missing or incorrect local image

No og:image tag appears

  • Check that the convention file is inside the App Router segment for the route you opened, not merely somewhere in the project.
  • Check for a more-specific opengraph-image file in a nested segment. It can take precedence over the ancestor image.
  • If metadata is defined with generateMetadata, inspect the generated page output and confirm the function supplies the expected image metadata for this route. Consult the generateMetadata reference.

The tag exists, but points to an unexpected URL

Use the value actually emitted in the head and open it directly. Next.js generates metadata for convention assets, including their URL, type, and dimensions. A wrong URL can indicate that a different route segment’s file is winning, or that the metadata logic is not producing the value you expected. Do not debug a URL you inferred from the source tree before checking the browser output.

The generated route errors or returns the wrong content

Request the image URL directly and inspect the development server output. This isolates the image handler from the page’s metadata tag. If the handler uses dynamic route segments on Next.js 16, verify that it awaits the promise-valued params before reading values used to build the image. For a static convention file, confirm its location and supported image extension against the file convention reference.

The layout differs from the browser page

ImageResponse is not a full browser renderer. Next.js documents support for common CSS properties and flexbox, but only a subset of CSS; advanced layouts such as CSS Grid are not supported. Simplify the image layout to supported properties and inspect the generated image itself rather than assuming your site’s regular stylesheet will render identically. Next.js Metadata and OG images

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A local edit does not show up

Generated metadata images are statically optimized and cached by default unless they use Dynamic APIs, uncached data, or dynamic configuration. Before treating a stale-looking result as a malformed tag, check the route’s rendering and caching behavior. Then reload the page, inspect the current tag, and open the emitted image URL again. Next.js Open Graph image conventions

Validate social crawler behavior on a public preview

Once the local page and image route work, deploy the branch to a preview URL that is reachable from outside your computer. Inspect that preview’s metadata and image URL, then use the target social platform’s own preview or debugging tool if available. Keep this as a separate check: a human browser’s successful localhost request does not show that a remote crawler can access the URL, and local rendering does not guarantee a platform will display the same card. Next.js notes that metadata delivery can differ between ordinary requests and HTML-limited crawlers; Vercel’s workflow likewise distinguishes a local endpoint from a deployed, publicly accessible path. Next.js generateMetadata · Vercel’s OG image guide

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For a public preview URL, ScreenshotNeo can capture a page with one GET request. Its capture is not a way to make a private localhost server reachable: publish a preview first and use that public URL. The request below saves a WebP screenshot of the page, so use it to inspect the rendered page visually; the metadata and image URL checks above remain the way to verify the emitted og:image value.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Replace https://stripe.com with your publicly accessible preview URL. See the ScreenshotNeo API documentation for the request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed; its MCP server lets AI agents take screenshots; and the Free plan includes 1,000 screenshots a month with no card, while paid plans start at $5 for 3,000. Learn about ScreenshotNeo, then sign up for 1,000 free screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a static file or generated image

Approach Useful when What to verify
Static opengraph-image file A route or group of routes can use a prepared image. Correct segment placement, file format, emitted URL, and whether a deeper segment overrides it.
Generated opengraph-image.js, .ts, or .tsx The image needs to be produced from route data or code. Direct route response, exported metadata values, supported CSS, dynamic route params, and caching behavior.

Both approaches can be tested with the same core sequence: inspect the emitted tag, open its resolved URL, and inspect the resulting image. The difference is whether you are validating a stored asset or a generated route and its rendering behavior.

Best Value
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Frequently Asked Questions

Can a social network fetch my localhost Open Graph image?

No. A remote crawler’s localhost points to its own environment, not your development machine. Use a publicly reachable preview URL to test crawler access.

Does a 1200 × 630 image guarantee the same card on every platform?

No. Next.js documents 1200 × 630 as an example image size; platforms can apply their own requirements and rendering behavior.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.