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 problemsTo take a screenshot from a SvelteKit endpoint, put the screenshot provider’s API key in a server-only environment variable and call its screenshot endpoint from a server route. The example below accepts a page URL, sends a JSON POST request to Screenshot API, and returns the provider’s screenshot URL to the caller. Validate and restrict the submitted URL before making the request: an endpoint that fetches arbitrary URLs can be abused.
Build a SvelteKit screenshot endpoint
This example uses Screenshot API’s documented POST /api/v1/screenshot request format: JSON in the request body and a bearer token in the Authorization header. It is an independently written SvelteKit route, not a claim that the provider’s separate SvelteKit guide was tested. The provider’s reference documents a returned screenshotUrl.
1. Store the API key on the server
Add the key to a local environment file that is excluded from source control:
SCREENSHOT_API_KEY=your_real_key
Read it only in server-side code. Do not put the key in a PUBLIC_-prefixed variable or browser-delivered JavaScript: a browser user can inspect client code and network requests. SvelteKit supports server-side application code, which makes a server route an appropriate place for this credential.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
2. Create the route
Create src/routes/api/screenshot/+server.js. The following route checks that the input is an HTTPS URL, limits the accepted host to an explicit allowlist, validates dimensions, handles upstream failures, and returns the provider’s JSON result.
import { json } from '@sveltejs/kit';
import { SCREENSHOT_API_KEY } from '$env/static/private';
const ALLOWED_HOSTS = new Set(['example.com', 'www.example.com']);
export async function POST({ request, fetch }) {
let input;
try {
input = await request.json();
} catch {
return json({ error: 'Request body must be valid JSON.' }, { status: 400 });
}
if (typeof input.url !== 'string') {
return json({ error: 'url must be a string.' }, { status: 400 });
}
let target;
try {
target = new URL(input.url);
} catch {
return json({ error: 'url must be an absolute URL.' }, { status: 400 });
}
if (target.protocol !== 'https:' || !ALLOWED_HOSTS.has(target.hostname)) {
return json({ error: 'URL host is not allowed.' }, { status: 400 });
}
const width = Number(input.width ?? 1280);
const height = Number(input.height ?? 720);
if (!Number.isInteger(width) || width < 1 || width > 4000 ||
!Number.isInteger(height) || height < 1 || height > 4000) {
return json({ error: 'width and height must be integers from 1 to 4000.' }, { status: 400 });
}
if (!SCREENSHOT_API_KEY) {
return json({ error: 'Screenshot API key is not configured.' }, { status: 500 });
}
let upstream;
try {
upstream = await fetch('https://api.screenshot-api.org/api/v1/screenshot', {
method: 'POST',
headers: {
Authorization: `Bearer ${SCREENSHOT_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: target.toString(),
viewport: { width, height },
format: input.format === 'jpeg' || input.format === 'webp' ? input.format : 'png',
fullPage: input.fullPage === true
})
});
} catch {
return json({ error: 'Could not reach the screenshot service.' }, { status: 502 });
}
if (!upstream.ok) {
return json({ error: 'Screenshot service returned an error.' }, { status: 502 });
}
let result;
try {
result = await upstream.json();
} catch {
return json({ error: 'Screenshot service returned invalid JSON.' }, { status: 502 });
}
if (typeof result.screenshotUrl !== 'string') {
return json({ error: 'Screenshot service response did not include screenshotUrl.' }, { status: 502 });
}
return json({ screenshotUrl: result.screenshotUrl });
}
$env/static/private is a server-only import. The allowed-host check is an example engineering safeguard, not a complete vendor-prescribed security recipe. Adjust the allowlist for your application’s needs; if users must capture arbitrary public sites, design explicit protections against requests to private or internal network addresses, redirects into restricted destinations, and abusive request volume. A hostname allowlist alone may not fit every deployment’s threat model.
3. Call your endpoint
From a client component or another trusted server-side caller, send the target URL to your own route—not the provider key:
const response = await fetch('/api/screenshot', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
url: 'https://example.com',
width: 1280,
height: 720,
format: 'png',
fullPage: true
})
});
const result = await response.json();
if (!response.ok) throw new Error(result.error);
console.log(result.screenshotUrl);
Render the returned URL as an image or redirect the browser to it, depending on your application. The provider’s getting-started material describes using a returned CDN URL or redirecting to image bytes. This example returns JSON so the caller can choose how to display or store the result.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Choose the capture options
Screenshot API documents both basic request settings and more advanced rendering controls. The route above deliberately exposes a small subset; add only options your application needs, and validate each one before forwarding it.
| Option | What it controls | When to use it |
|---|---|---|
url |
Page to capture | Required target. Validate scheme and permitted destinations server-side. |
viewport |
Width and height of the browser viewport | Match a desktop or mobile layout; the route validates integer dimensions. |
format |
PNG, JPEG or WebP output | Use PNG for lossless UI detail, or JPEG/WebP where smaller files suit the workflow. PNG is the documented default. |
fullPage |
Whether to capture the full scrollable page | Use for long articles or pages; the documented default is false. |
| Selector and selector wait | Capture a CSS-selected element and/or wait for a selector | Useful when only a chart, card, or report section matters, or when content renders asynchronously. |
| Wait strategy and delay | When capture begins relative to navigation or a specified delay | Use when a page needs time to render. A longer wait can increase response time. |
| Dark mode, timezone and locale | Emulated page appearance and regional settings | Use when the screenshot must reflect a specific theme or locale. |
| CSS/JavaScript injection and hidden selectors | Modify or hide page elements before capture | Use to remove irrelevant UI or prepare a page for a particular image. |
| Geolocation and PDF settings | Location emulation and PDF output configuration | Use for location-sensitive pages or document capture. |
The API reference says advanced options such as CSS/JavaScript injection, hidden selectors, geolocation, and PDF settings are POST-only. Basic GET requests use query parameters; POST sends JSON and supports the advanced configuration. Consult the current API reference for the exact parameter names and allowed values before expanding the route.
Operational limits, defaults, and cost
As documented by Screenshot API when its reference was accessed on September 29, 2026, the service defaults include deviceScaleFactor: 1, waitUntil: networkidle2, a 30,000 ms navigation timeout, caching enabled, a cache TTL of 86,400 seconds, and a stale TTL of 43,200 seconds. These are documented settings, not guarantees that apply forever or to every future account configuration. A cache hit may change whether a request performs a fresh capture; check the provider’s current reference if that distinction affects your use case.
The same documentation states free-plan limits of 60 requests per minute and 500 screenshots per month. Those are vendor-published limits, not independently verified account terms. Confirm current pricing and quotas before depending on them in production. The sources provide no independent cost, reliability, or speed benchmark comparing the hosted service with a locally run browser.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
- Use a route-level rate limit or authentication if the endpoint is not intended for unrestricted public use.
- Set caller and upstream timeouts appropriate to your application; the documented navigation timeout is not necessarily the total time your SvelteKit request will take.
- Decide whether to return a URL or stream image bytes. Returning a URL keeps this route simple; streaming bytes gives your application more control over delivery but requires handling the provider’s response format and headers.
- Log request IDs and sanitized failure details for diagnosis. Avoid logging API keys or sensitive target URLs.
Alternative: run Playwright yourself
If you need control over browser lifecycle, test setup, or image post-processing, Playwright is a software alternative to a hosted screenshot API. Its official documentation shows saving a page screenshot to a file, capturing the full page, returning a buffer, and capturing an element. A locally managed browser avoids a screenshot-provider API key, but your selected runtime must be able to run browser automation; confirm platform support separately.
import { chromium } from 'playwright';
const browser = await chromium.launch({ headless: true });
try {
const page = await browser.newPage({ viewport: { width: 1280, height: 720 } });
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'screenshot.png', fullPage: true });
// For one element instead:
// await page.locator('.header').screenshot({ path: 'header.png' });
} finally {
await browser.close();
}
This standalone example is Node.js browser automation, not a complete SvelteKit route. Integrating it into a server endpoint requires installing and deploying Playwright and its browser runtime in a compatible environment. The cited documentation describes the screenshot mechanics, but does not establish deployment feasibility for a particular hosting platform.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. Its website screenshot API can return PNG, JPEG, WebP, or PDF from a request. For a SvelteKit server route, keep the access key in a server-only variable and call it like this:
const response = await fetch('https://api.screenshotneo.com/v1/shot?access_key=YOUR_API_KEY&url=https%3A%2F%2Fexample.com');
if (!response.ok) throw new Error(`ScreenshotNeo returned ${response.status}`);
const image = Buffer.from(await response.arrayBuffer());
See the ScreenshotNeo API documentation for request options. Cookie banners are accepted as a visitor and removed along with 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, failed loads, timeouts, and cache hits are never billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Free tools Windows power users keep installed
One-click scans. No signup required.
Create a free ScreenshotNeo account to try 1,000 screenshots a month with no card.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Troubleshooting
Your SvelteKit route returns 400
Check that the caller sends valid JSON with a string url, that it is an absolute HTTPS URL, and that its hostname is in the allowlist. Width and height must be integers in the permitted range. Add a host only when the application has a reason to capture it.
The route returns 500 for a missing key
Confirm SCREENSHOT_API_KEY is set in the environment where the server runs, then restart the development server or redeploy so the environment is loaded. Keep the variable private; do not move it into client code to resolve a server configuration problem.
The route returns 502
The example uses 502 for a network failure, non-success response, invalid upstream JSON, or a response without screenshotUrl. Inspect the provider’s current API documentation and account status, and add carefully sanitized server-side diagnostics to distinguish these cases. The example intentionally does not forward the upstream response body, which could expose provider details to callers.
The screenshot is incomplete or too slow
Try a selector wait or a suitable delay for content that loads after navigation, or choose full-page capture for content below the initial viewport. Waiting longer can increase latency; a timeout does not guarantee a successful capture. If the issue persists, check whether the destination itself requires authentication or renders differently to automated browsers.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
The deployed Playwright route cannot launch a browser
Check that the deployment runtime supports the browser binaries and dependencies required by your Playwright setup. The existence of a working local capture does not prove that a serverless or restricted runtime can launch the same browser. If you cannot provide that runtime, use a hosted screenshot API instead.
FAQ
Can I expose a screenshot endpoint to the public?
You can, but an unrestricted endpoint that accepts arbitrary URLs can be misused and can create unexpected service usage. Require authentication or rate limits where appropriate, and constrain destinations according to your application’s security needs.
Does this route return image bytes?
No. The example returns JSON containing the provider’s screenshotUrl. The provider documents CDN URLs or redirects to image bytes as possible consumption paths; adapt the route if your application specifically needs a binary response.
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.

