Refract

NAME — on-the-fly image transforms, optimization, and global edge delivery over your existing image origin, driven by URL parameters.

https://demo.refract.dev/hero.jpg?w=1200&fm=auto&q=80

Quickstart

  1. 1

    Create an API key and connect your image origin. Refract points at an existing origin — there is no re-upload. Originals are fetched on demand and cached at the edge, never stored permanently.

  2. 2

    Request your first transform. Append a query string to any image path:

    https://demo.refract.dev/hero.jpg?w=1200&fm=auto&q=80
  3. 3

    Automate with the SDK. The helper builds the same URL from a typed options object:

    import { refract } from "@refract/js";
    
    const url = refract("hero.jpg", { width: 1200, format: "auto", quality: 80 });
    // → https://demo.refract.dev/hero.jpg?w=1200&fm=auto&q=80

Parameters

Ten chainable parameters. Seven are applied to the pixels; fm, q, and dpr are NEGOTIATED at the edge and travel in the URL.

NameValuesDescription
winteger, pxOutput width.
hinteger, pxOutput height; omit to keep the source aspect ratio.
fitcover, contain, fill, cropResize mode.
fm NEGOTIATEDjpeg, png, webp, avif, autoOutput format; auto negotiates AVIF → WebP → JPEG from the Accept header.
q NEGOTIATED1–100 (default 75)Re-encode quality.
dpr NEGOTIATED1–3Device pixel ratio.
cropsmart, center, edgesCrop strategy; smart keeps the subject in frame.
rot90, 180, 270Rotation, degrees clockwise.
blur0–100Gaussian blur radius.
bghex colorBackground fill for fit=contain.

Optimize

fm=auto negotiates AVIF → WebP → JPEG from the request's Accept header, so each client receives the smallest format it can decode. Across typical libraries this averages a 62% payload reduction versus the source JPEG.

Deliver

Transformed variants are served from 41 edge locations. Cached responses return at a p50 of 21 ms with a 98.6% cache hit ratio; a cold transform completes at p50 89 ms / p99 340 ms.

Caching & limits

Limits
  • Rate limit: 50 requests/second per key, on all tiers.
  • Transformed variants are cached at the edge for 30 days.
  • Instant purge by URL or tag.