Skip to content

Framework Integrations

Dus Mamud edited this page Nov 9, 2026 · 1 revision

Framework Integrations

React, Vue and Svelte each get a first-class package built on one shared, framework-free processor store — same state machine (idle → processing → success/error), same progress steps (decode → transform → encode → done), everywhere.

React — @dusrel/image-react

import { useProcessImage } from '@dusrel/image-react';

export function Shrink({ file }: { file: File }) {
  const { process, processing, progress, result, error, reset } = useProcessImage();

  return (
    <button
      disabled={processing}
      onClick={() => process(file, { format: 'image/webp', quality: 0.8 })}
    >
      {processing ? `Working… ${(progress * 100) | 0}%` : 'Convert to WebP'}
    </button>
  );
}

Batch work: useProcessBatch (adds completed / total / results). Crop UI: the typed <DusrelCrop src aspect="16/9" onCropChange={...} /> component. Hooks reference: package README.

Vue — @dusrel/image-vue

import { useProcessImage } from '@dusrel/image-vue';

const { process, processing, progress, result, error, reset } = useProcessImage();

await process(file, { format: 'image/avif', maxSizeBytes: 200_000 });

Everything is refs, ready for templates. The <DusrelCrop> component supports v-model for the crop rect. Composables reference: package README.

Svelte — @dusrel/image-svelte

<script>
  import { createProcessImage } from '@dusrel/image-svelte';

  const { process, status, progress, result, error } = createProcessImage();
</script>

<button onclick={() => process(file, { format: 'image/webp' })}>
  {$status === 'processing' ? `Working… ${($progress * 100) | 0}%` : 'Convert'}
</button>

Svelte 5 (runes-era) stores you subscribe to with $. DusrelCrop.svelte ships as source and binds with bind:crop. Store reference: package README.

Vanilla / no framework

You don't need one — @dusrel/image is framework-free, and the crop UI is a plain Web Component (<dusrel-crop>) that works in any page. See Getting Started.


More snippets: dusmamud.github.io/dusrel-image/guide/frameworks

Clone this wiki locally