Framework integrations
Keenpix is just a URL, so it drops into any framework that renders an image.
Keenpix has no SDK. Integrating it means producing the right URL and putting it in an
<img> (or your framework's image component). There are two flavours:
- Pluggable loaders — frameworks with a built-in image component you can point at a custom backend: Next.js and Nuxt.
- URL builder + native
<img>— everywhere else. A tiny helper builds the URL and you render a normal image withsrcsetfor responsiveness.
The universal pattern
Drop this helper anywhere (it's framework-agnostic — plain TypeScript):
// keenpix.ts
const HOST = 'https://keenpix.example.com'
const PROJECT = 'YOUR_PROJECT_ID'
type Opts = { w?: number; h?: number; q?: number; fmt?: string; fit?: string; dpr?: number }
export function keenpix(src: string, opts: Opts = {}): string {
const params = new URLSearchParams({ project: PROJECT })
for (const [k, v] of Object.entries(opts)) {
if (v != null) params.set(k, String(v))
}
return `${HOST}/img/${encodeURIComponent(src)}?${params.toString()}`
}
// A responsive srcset across common widths.
export function keenpixSrcSet(src: string, widths = [640, 960, 1280, 1920], opts: Opts = {}) {
return widths.map((w) => `${keenpix(src, { ...opts, w })} ${w}w`).join(', ')
}Then render a fully responsive, auto-format image with native HTML:
<img
src="${keenpix('/hero.jpg', { w: 1280 })}"
srcset="${keenpixSrcSet('/hero.jpg', [640, 960, 1280, 1920])}"
sizes="100vw"
loading="lazy"
decoding="async"
alt="Hero"
/>Omitting fmt is the same as fmt=auto: Keenpix negotiates from the request's
Accept header and returns AVIF, WebP, or JPEG. Add fmt: 'webp', fmt: 'avif', or
fmt: 'svg' only when you want a fixed output format. SVG output is explicit; an SVG
origin with fmt=auto is rasterized instead of returned as SVG.
Tip: read HOST and PROJECT from environment variables so you can swap instances per
environment without touching component code.
Pick your framework
Next.js
Custom next/image loader
Nuxt
@nuxt/image custom provider
TanStack Start
URL builder + <img>
React (Vite)
A <KeenpixImage> component
Vue
Bind :src to the helper
SvelteKit
Helper + <img>
Astro
Remote images via <img>
Remix
Helper + <img>
Plain HTML
Any backend, any language
Don't see yours? If it can render an <img> tag, the universal pattern
above already works — that includes Angular, Solid, Qwik, Gatsby, Laravel, Rails, Django,
WordPress, and static-site generators.