React image optimization for Supabase Storage

The @prodkit-cloud/react package wraps the URL API in an Image component with automatic srcset, lazy loading, and format negotiation. Works with Vite, CRA, Remix, or any React setup.

SDK coming soon

@prodkit-cloud/react isn't published yet, so the guides below skip the install step. Until it is, build image URLs from your endpoint with URL parameters. They work in any React app with no package:

URL API

<img
  src="https://img.prodkit.cloud/acme/avatars/cory.png?width=256"
  width={128}
  height={128}
  alt="Avatar"
  loading="lazy"
/>

Configure the provider

Wrap your app in ProdKitProvider with your project slug from the dashboard. Every Image below it resolves paths against your endpoint.

Example

import { ProdKitProvider } from "@prodkit-cloud/react"

createRoot(document.getElementById("root")!).render(
  <ProdKitProvider project="acme">
    <App />
  </ProdKitProvider>,
)

Render an image

Pass props instead of query parameters. The component generates srcset variants, sets loading="lazy" by default, and reserves layout space from width and height.

Example

import { Image } from "@prodkit-cloud/react"

export function Avatar({ avatar }: { avatar: string }) {
  return <Image src={avatar} width={128} height={128} alt="Avatar" />
}

Crop to faces and remove backgrounds

Cloudflare Images finds faces and subjects for you. gravity="face" keeps faces in frame when cropping, and removeBackground (beta) returns a transparent cutout. Each combination of options counts as one of the image's five included sizes.

Example

<Image src={avatar} width={96} height={96} gravity="face" zoom={0.6} alt="Avatar" />

<Image src="products/sneaker.jpg" width={800} removeBackground alt="Sneaker" />

Blur-up placeholders

placeholder="blur" paints a tiny blurred version of the image (32px wide, blurred by Cloudflare Images) behind it until the full image loads, so layouts never flash empty boxes.

Example

<Image src="covers/launch.jpg" width={1200} height={630} placeholder="blur" alt="Launch cover" />

Migrate existing Supabase URLs

Image accepts full Supabase Storage URLs and rewrites them to your ProdKit endpoint, so you can migrate one component at a time.

Example

<Image
  src="https://xyz.supabase.co/storage/v1/object/public/avatars/cory.png"
  width={128}
  height={128}
  alt="Avatar"
/>

Image props

Every prop except src, project, and width is optional. buildImageUrl and buildSrcSet are available for custom components.

NameDescriptionValuesDefault
srcImage path within your project, or a full Supabase Storage URL to rewrite.stringRequired
projectProject slug from the dashboard. Can be passed through ProdKitProvider.stringRequired
imageBaseUrlCustom image service base URL for self-hosted or preview environments.absolute URLhttps://img.prodkit.cloud
widthRendered width in CSS pixels. Also caps the generated srcset variants.1-4096Required
heightRendered height in CSS pixels.1-4096Auto from aspect ratio
qualityCompression quality.1-10082
fitHow the image fills the requested dimensions.scale-down, contain, cover, crop, padscale-down
formatOutput format. auto negotiates AVIF or WebP per browser.auto, avif, webp, jpeg, pngauto
gravityWhere cover and crop fits keep the image: face (detected faces), auto (the most interesting region), a side, or a focal point XxY from 0 to 1. Sets fit=cover unless you choose a fit."auto", "face", "top", "bottom", "left", "right", { x, y }Center
zoomWith gravity=face, how tightly to crop around faces, from 0 (loose) to 1 (tight).0-1None
blurBlur radius, rounded to a standard level. With a small width, makes a lightweight placeholder.1-250None
sharpenSharpening strength. 1 suits most downscaled images.0-10None
removeBackgroundCuts out the subject with a transparent background (beta).booleanfalse
placeholderblur shows a tiny blurred version of the image until it loads, generated by ProdKit (no blurDataURL needed). It counts as one of the image's sizes.blur, emptyempty