Builder.io

Provider documentation

Builder.io

Transform images returned by the Builder.io Image API.

Setup

Install the framework package and the core package for the provider import:

npm install @desource/image @desource/image-svelte

Save this as image.config.ts beside your example component. Replace sample domains and identifiers with your own.

import type { ImageConfig } from '@desource/image';
import { builderioProvider } from '@desource/image/providers/builderio';

export const imageConfig = {
  provider: 'builderio',
  providers: {
    builderio: builderioProvider()
  }
} satisfies ImageConfig;

Registering this provider makes it the default for the configured components. To mix services, register each provider and set provider="builderio" on the image that should use this one.

Image source

Pass the complete Builder.io asset URL; this adapter does not prepend a baseURL.

https://cdn.builder.io/api/v1/image/assets/your-space/your-asset

Usage

The example uses the shared configuration above and the Svelte image component.

<script lang="ts">
  import { Image, setImageConfig } from '@desource/image-svelte';
  import { imageConfig } from './image.config';

  setImageConfig(imageConfig);
</script>

<Image
  src="https://cdn.builder.io/api/v1/image/assets/your-space/your-asset"
  alt="Sample image" width={800} height={500}
  modifiers={{
  "format": "webp",
  "quality": 80,
  "fit": "cover"
}}
/>

Provider options

This provider needs no service-specific factory options. Register the factory with no arguments.

Pass shared defaults such as screens, domains, aliases and presets to the image configuration. Pass provider-specific defaults as modifiers in the provider factory.

Modifiers

Maps width, height, format, quality, fit and position to Builder.io query parameters.

Set dimensions on the component and pass service-specific operations through modifiers, as shown above. See the provider source for exact mappings and the service documentation for accepted values.

Provider notes

  • Source query parameters are preserved. Use WebP for fit and position transformations supported by the Builder.io API.
← Back to all providers