Documentation

Integration

Fetch-native previews at the edge.

linkpeek uses platform fetch, Web Streams, TextDecoder, and AbortController. It needs no Node HTTP client or DOM implementation.

Create a Worker endpoint

npm install linkpeek
import { preview } from "linkpeek";

export default {
	async fetch(request: Request): Promise<Response> {
		const url = new URL(request.url).searchParams.get("url");
		if (!url) return Response.json({ error: "Missing url" }, { status: 400 });

		try {
			const result = await preview(url);
			return Response.json(result, {
				headers: {
					"Cache-Control": result.statusCode < 400
						? "public, max-age=3600"
						: "no-store",
				},
			});
		} catch {
			return Response.json({ error: "Preview unavailable" }, { status: 422 });
		}
	},
};

Let the edge absorb repeat work

For public preview endpoints, normalize the URL into a stable cache key and cache only validated 2xx/3xx results. Add rate limiting before exposing arbitrary outbound fetches to the internet.

Know what the runtime owns

linkpeek validates literal addresses and each redirect target. The Worker runtime still owns final DNS resolution and connection establishment. Keep private-IP access disabled and use platform egress controls when hostile public input is in scope.