Prerequisites: a CDN endpoint and either Convertly Storage file IDs or a configured origin source. Install
@convertly-sh/image before using the React examples below.Resolution switching vs art direction
Rule of thumb: if only the pixel width changes, use
<ConvertlyImage>. If the composition changes, use <picture>.

One source image — four <picture> breakpoints with different aspect ratios and fit=cover crops.
<picture> picks the matching <source>. Chrome may fetch twice in the inspector — that is a tooling quirk, not double-loading in production.
<ConvertlyCdnProvider> — configure once
<ConvertlyCdnProvider> is a React context wrapper that creates one shared CDN client (createConvertlyCdn) for every <ConvertlyImage> and <ConvertlyVideo> underneath it.
Why use it
- DRY config — set
namespaceonce in your root layout instead of on every image. - Single CDN instance — avoids recreating the URL builder on every render.
- Composable — child components call
<ConvertlyImage src="…" />without knowing env vars.
namespace directly on <ConvertlyImage>, or use the framework-agnostic createConvertlyCdn() in Astro, Svelte, or plain HTML. Vue uses provideConvertlyCdn() for the same pattern; Solid uses <ConvertlyCdnProvider> identically to React.
Resolution switching with <ConvertlyImage>
<ConvertlyImage> renders a real <img> with Convertly CDN URLs. When you pass width and sizes, it automatically builds a responsive srcSet using defaultWidths() and sets format=auto + gravity=auto by default.

Same composition, different widths — the browser picks a srcset candidate (320w left, 1200w right).
Origin-backed images
For assets on a registered origin source (e.g. deployedpublic/ folder):
Custom width lists
Override the default breakpoint ladder when your layout needs specific steps:Next.js: global loader instead of per-component markup
If you usenext/image everywhere, wire createConvertlyLoader once — every <Image> gets CDN URLs without switching to <ConvertlyImage>. Use <ConvertlyImage> when you need transform props (preset, text overlays, gravity=face) that next/image does not pass through.
Art direction with <picture>
Use <picture> when the crop or aspect ratio should change at a breakpoint — for example a wide landscape hero on desktop and a tall portrait crop on mobile.
Convertly does not ship a <ConvertlyPicture> component today. Build <picture> with the URL builder; each <source> gets its own transform params.
Plain HTML
Replace{endpointNamespace} and {fileIdOrSlug} with your values:


Source landscape (top) — the same file reframed at each breakpoint below.
React with the URL builder
<ConvertlyCdnProvider>, call useConvertlyCdn() inside child components instead of creating a second client:
Adding srcset per breakpoint
For art-directed sources that also need multiple widths within a breakpoint, combine cdn.srcset() on each <source>:
Automated cropping for art direction
When the subject is not centred, pick a gravity mode per breakpoint instead of pre-cropping assets:
Portrait square crop — gravity=center (left) vs gravity=face (right) on a group photo.
Retina and high-DPI screens
Convertly uses width descriptors insrcset (320w, 640w, …). The browser picks a URL whose width matches the rendered size × device pixel ratio. You do not need separate 1x / 2x density descriptors — include widths up to ~2× your layout width (which defaultWidths() does automatically).
Alternative: fixed layout width + dpr=2 on the URL. See Device pixel ratio and Client Hints when the slot width is fluid.
Example: an image displayed at 600px CSS width on a 2× screen may request the 1200w candidate from the set.

Width descriptors cover retina — a 600px layout slot on a 2× display typically selects the 1200w URL from the generated set.
Quick reference
Related docs
- Framework SDKs — full prop tables and Vue/Svelte/Solid adapters
- Image CDN setup — origin sources, namespaces, first deploy
- Smart cropping — focal points and analyze API
- Resize, crop & fit —
fit,gravity, and crop examples