Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
FREEDOM251

Freedom251 › Blog › API integration

How to Add Website Screenshot Cards to a Next.js App with URL2PNG

By Freedom251 Team · · 8 min read

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

To add a URL2PNG screenshot card in Next.js, generate the signed URL on the server, then render that URL as the card’s image. URL2PNG’s v6 request uses an API key and a token derived from the complete query string and your account secret. Keep the secret out of browser code. URL2PNG documents Node.js examples, but its reviewed documentation does not provide a Next.js-specific recipe or claim a Next.js package.

How the integration fits together

Your Next.js app supplies a target page URL and capture options to URL2PNG. URL2PNG renders that page and returns a screenshot; your app displays the resulting image in a card. The signing step must happen in server-side code because it uses your account secret. The service describes its product as a way to capture snapshots inside an app and documents viewport, thumbnail, and full-page options (URL2PNG).

As an Amazon Associate I earn from qualifying purchases.

The implementation below is a server-side pattern based on URL2PNG’s documented request anatomy, not a vendor-provided Next.js integration. The exact encoding of the query string is part of the signature, so verify it against the current URL2PNG Quickstart Guide and the version of any package you install before deploying.

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

Build a signed screenshot URL on the server

Set server-only credentials

Store the URL2PNG API key and account secret in server environment variables, for example URL2PNG_API_KEY and URL2PNG_SECRET. Do not prefix either with NEXT_PUBLIC_: Next.js exposes variables with that prefix to client-side code. Add them to your deployment provider’s server environment configuration as well as your local development environment.

#1 Best Overall
HP OmniBook 3 17.3 inch Laptop PC, FHD Display, AMD Ryzen 3 30, 8 GB RAM, 512 GB SSD, AMD Radeon 610M Graphics, Windows 11 Home, Mica Silver, 17-dp0199nr
  • FULL HD IPS DISPLAY - Enjoy vibrant, crystal-clear images with 178-degree wide-viewing angles
  • AMD RYZEN 3 30 PROCESSOR - Everyday performance you can count on; Multitask, stream, game casually, and edit photos smoothly with responsive power and vibrant HDR visuals
  • ENJOY UP TO 14 HOURS AND 15 MINUTES OF BATTERY LIFE - HP Fast Charge restores battery from 0 to 50% in approximately 45 minutes
  • AMD RADEON 610M GRAPHICS - Experience smooth entertainment; Built for streaming and multitasking, enjoy realistic visuals and efficient performance for work and play
  • STORAGE AND MEMORY - 512 GB PCIe NVMe M.2 SSD offers fast speed and efficient storage; and 8 GB LPDDR5 RAM memory boosts performance with higher bandwidth

Server helper example

URL2PNG’s documented Node.js example uses the url2png package and its buildURL or readURL methods. The helper below instead illustrates the signing design directly. It assumes that URL2PNG expects an MD5 token calculated from the exact encoded query string concatenated with the account secret. Confirm the current endpoint path, parameter names, encoding, and token format against the vendor guide; do not treat this unverified adaptation as tested code.

import { createHash } from 'node:crypto';

const API_KEY = process.env.URL2PNG_API_KEY;
const SECRET = process.env.URL2PNG_SECRET;

if (!API_KEY || !SECRET) {
  throw new Error('Missing URL2PNG_API_KEY or URL2PNG_SECRET');
}

function validateTarget(raw: string): string {
  const target = new URL(raw);
  if (target.protocol !== 'https:' && target.protocol !== 'http:') {
    throw new Error('Target URL must use HTTP or HTTPS');
  }
  return target.toString();
}

export function buildUrl2PngUrl(rawTarget: string) {
  const target = validateTarget(rawTarget);
  const params = new URLSearchParams();
  params.set('url', target);
  params.set('viewport', '1280x800');
  params.set('thumbnail_max_width', '640');
  params.set('fullpage', 'false');

  // Sign the exact serialized query string that will be sent.
  const query = params.toString();
  const token = createHash('md5').update(query + SECRET).digest('hex');
  return `https://api.url2png.com/v6/${API_KEY}/${token}/png/?${query}`;
}

The endpoint and path layout shown here reflect the v6 request description in URL2PNG’s Quickstart; confirm the current details there before use. Do not reorder, re-encode, or append parameters after signing. The value hashed and the query string sent must match exactly. If you use the official package instead, follow its current API and encoding behavior rather than combining its output with a separate signing scheme.

Return the URL from server-side code

For example, an App Router route handler can build the image URL without exposing credentials. Validate and authorize the target URL in your real application: accepting arbitrary URLs from untrusted users can create a server-side request risk and unwanted screenshot usage.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
HP 14" HD Chromebook Laptop for Students, Intel Quad-Core N4120(> N4020), 4GB RAM, 64GB eMMC, WiFi, Webcam, HDMI, USB-A&C, 14 Hours Battery Life, Zoom, Chrome OS, CUE Accessories
  • Intel Celeron N4120: 4 Cores & Threads, 1.1GHz Base Clock, Up to 2.6GHz Boost Clock, 4MB Cache, Intel UHD Graphics 600. The perfect combination of performance, power consumption, and value helps your device handle multitasking smoothly and reliably with four processing cores to divide up the work.
// app/api/screenshot/route.ts
import { NextResponse } from 'next/server';
import { buildUrl2PngUrl } from '@/lib/url2png';

export async function GET(request: Request) {
  const { searchParams } = new URL(request.url);
  const target = searchParams.get('url');
  if (!target) {
    return NextResponse.json({ error: 'Missing url parameter' }, { status: 400 });
  }

  try {
    const imageUrl = buildUrl2PngUrl(target);
    return NextResponse.json({ imageUrl });
  } catch {
    return NextResponse.json({ error: 'Invalid screenshot request' }, { status: 400 });
  }
}

This example returns the generated URL, rather than proxying screenshot bytes. A server component can also call the helper directly when it already has a trusted target URL. For a public API route, add authorization, input limits, and an allowlist or other policy appropriate to your app.

Render the screenshot as a card

The screenshot is an external image. The card’s layout, dimensions, loading state, and accessible text are your app’s responsibility. A plain image element avoids Next.js remote-image configuration; if using next/image, configure the relevant remote host according to your Next.js version and deployment setup.

type ScreenshotCardProps = {
  imageUrl: string;
  pageTitle: string;
  pageUrl: string;
};

export function ScreenshotCard({ imageUrl, pageTitle, pageUrl }: ScreenshotCardProps) {
  return (
    <a className="screenshot-card" href={pageUrl} target="_blank" rel="noreferrer">
      <img src={imageUrl} alt={`Screenshot preview of ${pageTitle}`} loading="lazy" />
      <span>{pageTitle}</span>
    </a>
  );
}
.screenshot-card {
  display: block;
  overflow: hidden;
  border: 1px solid #d8dce2;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.screenshot-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}
.screenshot-card span {
  display: block;
  padding: 0.75rem 1rem;
}

Use alt text that describes the image’s purpose rather than repeating an adjacent title without context. If the screenshot is decorative because the same linked destination and title are already clearly conveyed, an empty alt attribute may be more appropriate.

Rank #3
Sale
AKCHART 15.6'' AI Laptop with Office 365 12GB RAM 256GB SSD Win 11 Laptops | 7000mAh Battery, IPS FHD, 180°Viewing, Quad-Core Processor, Type-C, WiFi5, Portable Thin Business Student Laptops, Light Gray
  • Stunning 15.6" FHD IPS Display: Experience crisp 1920x1080 resolution on this 15.6 inch laptop with an IPS panel that delivers wide viewing angles and vivid colors. The narrow-bezel design maximizes screen real estate for comfortable viewing on this Win 11 laptop, whether you're studying or working.
  • Celeron J4105 Processor & 256GB SSD: Powered by a reliable Celeron J4105 processor paired with 12GB DDR4 memory and a fast 256GB M.2 SSD. This laptop computer supports SSD expansion up to 2TB and TF card expansion up to 1TB, so your storage grows with your needs. Delivers smooth multitasking for daily productivity.
  • AI-Powered Win 11 Laptop: Built-in AI features enhance your productivity with smart assistance for writing, summarizing, and task management. Pre-installed with Win 11 and includes Office 365 subscription. This student laptop is backed by 1-year warranty and 24/7 customer support.
  • All-Day 7000mAh Battery & 180° Hinge: The high-capacity 7000mAh battery keeps this laptop powered through long classes or meetings. The 180-degree lay-flat hinge lets you share your screen effortlessly during presentations. This durable laptop computer adapts to your dynamic workflow.
  • Versatile Connectivity Hub: Equipped with USB 3.2, Type-C, Mini HDMI, and 3.5mm audio jack to connect all your peripherals. Stay online anywhere with high-speed 5G WiFi and Bluetooth 4.2. This college laptop keeps you connected at home, in the library, or on the go.

Choose capture options for the card

URL2PNG’s Quickstart documents the options below. Defaults and accepted formats are service-specific; check the current guide before relying on them.

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.
Option What it changes When to use it
viewport Browser render dimensions; the guide gives a default of 1480×1037. Set dimensions to match the kind of page preview you want. A viewport capture suits compact cards.
thumbnail_max_width Scales output to a maximum width. Limit image size to suit the card while preserving enough detail for the preview.
fullpage Attempts to capture the full document instead of just the viewport; documented default is false. Use when users need to inspect the whole target page. For a small card, a viewport image is usually easier to scan.
delay Waits after document readiness and asset loading. Allow more time for pages that render content after initial load.
custom_css_url Provides custom CSS for the capture. Adjust the rendered page’s appearance where a capture-specific stylesheet is useful.
say_cheese Capture-related setting named in the Quickstart. Consult the current guide for its accepted values and precise effect.
accept_languages Controls language preferences sent for the page. Use when the target site varies its content by requested language.
user_agent Controls the browser user-agent value used for capture. Use only when you need a particular user-agent presentation; some sites may respond differently.
unique Changes the cache key to request a fresh capture. Vary it when content changes and the card must reflect a newer render.
ttl Sets cache lifetime in seconds; the Quickstart documents a default of 2,592,000 seconds (30 days). Choose a cache duration that fits how quickly the target page changes.

These choices involve a trade-off: full-page coverage can produce a taller image than a compact preview needs, while forcing a fresh capture favors recency over reuse of a cached result. Those are integration choices based on the documented controls, not URL2PNG performance guarantees.

Understand caching, freshness, and render usage

URL2PNG’s plans page says cached screenshots are retained for 30 days, and retrieving a cached image does not count against plan usage; a newly generated screenshot counts as a render. The Quickstart’s documented default TTL is also 2,592,000 seconds. If a target page changes, vary unique to request a new capture; using a stable value allows matching requests to reuse the cache. Plan quotas and billing terms can change, so consult the live URL2PNG plans page for current details.

Rank #4
HP Essential Laptop 2026, Intel CPU, 128GB Storage, Office 365, Windows 11 | Copilot AI, WiFi 6, Long Battery Life, Lightweight & Portable, Online Learning, Browsing, Streaming, Willow Green
  • Efficient Performance for Everyday Computing: Powered by Intel N150 processor with up to 3.6 GHz Intel Turbo Boost Technology, 6 MB L3 cache, 4 cores, and 4 threads, this HP laptop delivers responsive performance for web browsing, streaming, document editing, and multitasking. Paired with 4GB LPDDR5 RAM and 128GB UFS storage, it handles daily tasks smoothly. Includes 1-year Microsoft 365 Personal subscription for Word, Excel, PowerPoint, and cloud storage to maximize your productivity.
  • 14-Inch HD Micro-Edge Display:Enjoy clear visuals on the 14-inch HD (1366 x 768) anti-glare screen with 250-nit brightness and 62.5% sRGB coverage. The micro-edge bezel delivers a 79% screen-to-body ratio in a compact design. An HP True Vision 720p HD camera with noise reduction and dual-array microphones supports clear video calls, remote work, and online learning.
  • Modern Connectivity and Wireless Technology: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.4 for seamless pairing with accessories. Versatile port selection includes 1 USB Type-C 10Gbps with DisplayPort 1.2 for external displays, 2 USB Type-A 5Gbps ports for peripherals, 1 HDMI 1.4b port, 1 headphone/microphone combo jack, and 1 multi-format SD media card reader. Connect monitors, transfer files quickly, and expand your workspace with ease.
  • All-Day Battery Life and Portable Design: Enjoy up to 11 hours of video playback, 7.5 hours of mixed usage, or 7.5 hours of wireless streaming on a single charge, perfect for students and professionals on the go. Weighing just 3.24 lb and measuring 12.76" x 8.86" x 0.71", this lightweight laptop fits easily in backpacks and bags. The stylish willow green top cover with matte finish and natural silver keyboard deck with vertical brushing pattern offer a modern, professional look.
  • AI-Enhanced Productivity: Access Microsoft Copilot instantly with the dedicated Copilot key for faster assistance. AI Noise Reduction filters background sounds and improves voice clarity during calls. Dual speakers provide clear audio, while the full-size natural silver keyboard and HP Imagepad support comfortable typing and navigation.

URL2PNG’s plans page, checked on 2026-10-03, displayed monthly options of 5,000 fresh screenshots for $29, 20,000 for $99, and 50,000 for $199, plus Enterprise, and said it offered no free account. These are volatile listed terms, not a guarantee of future pricing. The same page gives plan-specific rates for additional screenshots; check it directly for the current terms before estimating cost.

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

Protect the integration and keep cards reliable

  • Keep signing server-side. The account secret must never be sent to a client component, serialized into HTML, or placed in a public environment variable.
  • Validate target URLs. Restrict schemes to HTTP or HTTPS, and consider an allowlist if users submit URLs. Prevent your app from becoming an unrestricted screenshot proxy.
  • Cache deliberately. A stable request can reuse cached output; use a changing unique value only when freshness is worth a new render.
  • Choose dimensions for the presentation. Set viewport and thumbnail width to fit the card rather than downloading an unnecessarily large image.
  • Expect third-party variation. A target site may change its layout, block capture, or render content late. Use an appropriate delay and provide a useful card fallback if the image fails to load.
  • Check current API behavior. URL signing depends on the exact query representation; a small encoding change can invalidate the token. Confirm package and endpoint details against URL2PNG’s documentation.

Troubleshooting common failures

Request rejected or token is invalid

Check that the API key and secret belong to the intended account, and that the token was computed from precisely the same encoded query string sent to the endpoint. Do not alter parameter order, encoding, or values after signing. Compare the implementation with URL2PNG’s current Quickstart.

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

The screenshot does not reflect a recent page change

The response may be served from cache. Vary the unique value to request a new capture, or set an appropriate ttl according to the current API documentation. A fresh screenshot counts as a render under the plans-page usage description.

Best Value
HP Essential Laptop, Intel N150 CPU, 4GB DDR5 RAM, 128GB SSD, Long Battery Life, 1TB Cloud Storage, Win 11 with Microsoft 365
  • 【Powerful Performance】Equipped with Intel N150 CPU, featuring up to 4.4 GHz, ensuring efficient and powerful multitasking capabilities.
  • Designed for mobility with a slim 0.71-inch profile and lightweight, making it easy to carry between home, office
  • 【Versatile Connectivity】 connected with multiple ports including USB 3.0 Type-C, and a headphone/mic combo jack, with Wi-Fi and Bluetooth for seamless wireless networking.
  • One Year Microsoft 365

The image is cropped or too large

Adjust viewport for the visible capture area and thumbnail_max_width for output sizing. Use fullpage only if the complete document is important to the card; otherwise the viewport capture is more suitable for a compact preview.

The page is missing late-loaded content

Try an appropriate delay for pages that need time after readiness and asset loading to finish rendering. The target site’s behavior determines how much delay is useful; the reviewed documentation does not establish a universal value.

The URL works locally but fails after deployment

Confirm that both server-side environment variables are configured in the deployed environment and available to the route or server component. Do not fix this by exposing the secret with a public variable prefix.

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

Next.js image configuration blocks the remote image

If you render with next/image, configure its allowed remote source for the URL2PNG image host using the configuration appropriate to your Next.js release. Alternatively, use a standard <img> element as in the card example.

Or skip the browser setup

ScreenshotNeo is an alternative screenshot API with an MCP server for AI agents. Its one-call API can return a screenshot without building a browser capture flow yourself. For example, using cURL:

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

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up free for 1,000 screenshots a month with no card.

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.

API integrationNext.jsURL2PNGWeb developmentwebsite screenshots

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.