
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
@7haven/h-image
Advanced tools
Production-ready Svelte 5 image component with automatic AVIF/WebP optimization, zero layout shift, and type-safe API
Production-ready Svelte 5 image component with automatic AVIF → WebP → fallback optimization
Type-safe • Zero Dependencies • Zero Layout Shift • CDN-Ready
$state, $derived, $effect)npm install @7haven/h-image
# Yarn
yarn add @7haven/h-image
# pnpm
pnpm add @7haven/h-image
# Bun
bun add @7haven/h-image
<script>
import { Image, configureCdn } from '@7haven/h-image';
// Optional: Configure your CDN
configureCdn({ baseUrl: 'https://cdn.example.com' });
</script>
<!-- Auto-optimized: AVIF → WebP → fallback -->
<Image src="file/hero" alt="Hero image" width={1200} aspectRatio="21/9" />
That's it! The component automatically:
<Image
src="file/hero"
alt="Hero banner"
width={1920}
aspectRatio="21/9"
fetchpriority="high"
loading="eager"
/>
<Image
src="file/product"
alt="Product thumbnail"
width={400}
aspectRatio="1/1"
transform={{ quality: 85 }}
/>
Different images for different screen sizes:
<Image
src="file/fallback"
alt="Responsive hero"
width={1200}
sources={[
{ src: 'file/desktop-wide', media: '(min-width: 768px)' },
{ src: 'file/mobile-square', media: '(max-width: 767px)' }
]}
/>
<Image
src="file/photo"
alt="Enhanced photo"
width={800}
transform={{
blur: 10,
brightness: 1.2,
quality: 90
}}
/>
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | required | Image source (CDN path or URL) |
alt | string | required | Alt text for accessibility |
width | number | - | Display width in pixels |
height | number | - | Display height in pixels |
aspectRatio | string | number | - | Aspect ratio (e.g., "16/9", 1.5) |
modernFormats | boolean | true | Auto-generate AVIF/WebP sources |
sources | ImageSource[] | - | Custom sources for art direction |
transform | TransformOptions | {} | CDN transformation options |
loading | 'lazy' | 'eager' | 'lazy' | Loading strategy |
fetchpriority | 'high' | 'low' | 'auto' | - | Resource priority hint |
placeholder | 'blur' | 'none' | string | 'blur' | Placeholder while loading |
fit | 'cover' | 'contain' | 'fill' | - | Object-fit behavior |
position | string | 'center' | Object-position value |
sizes | string | auto | Custom sizes attribute |
class | string | - | Additional CSS classes |
<Image src="file/hero" alt="Hero" width={1200} sizes="(min-width: 1024px) 50vw, 100vw" />
<Image
src="file/portrait"
alt="Person"
width={400}
height={400}
fit="cover"
position="top center"
/>
<Image src="file/legacy" alt="Legacy browser support" width={800} modernFormats={false} />
<Image src="file/hero" alt="Hero" width={1200} placeholder="data:image/svg+xml,..." />
width + height OR aspectRatio to prevent CLSfetchpriority="high" + loading="eager" for LCP images onlymodernFormats={true} (default) for 30-50% smaller file sizessizes attribute for responsive layoutsquality: 85 for optimal size/quality balancecontain for rendering performanceURL API)alt text is required (TypeScript enforced)<picture>, <img>)role propimport { configureCdn } from '@7haven/h-image';
// Configure once in your root layout
configureCdn({
baseUrl: 'https://cdn.example.com'
});
| Transform | Type | Description |
|---|---|---|
format | 'avif' | 'webp' | 'auto' | Output format |
width | number | Resize width |
height | number | Resize height |
fit | 'cover' | 'contain' | 'fill' | Resize behavior |
quality | number (1-100) | Image quality |
blur | number | Blur intensity |
sharpen | number | Sharpen intensity |
brightness | number | Brightness level |
contrast | number | Contrast level |
saturation | number | Saturation level |
rotate | number | Rotation degrees |
[400, 800, 1200, 1600] + // Standard
2048; // When zoom={true}
import { Image } from '@7haven/h-image';
import { configureCdn, getCdnConfig } from '@7haven/h-image';
// Configure CDN
configureCdn({ baseUrl: 'https://cdn.example.com' });
// Get current config
const config = getCdnConfig();
import {
buildImageUrl, // Build CDN URL
generateSrcset, // Generate srcset string
generateSizes, // Generate sizes attribute
calculateHeight, // Calculate height from aspect ratio
generateBlurPlaceholder // Generate blur placeholder
} from '@7haven/h-image';
import { COMPONENT_VERSION } from '@7haven/h-image';
console.log(COMPONENT_VERSION); // '1.0.0'
import type {
ImageProps, // Component props
ImageSource, // Source object for art direction
TransformOptions, // CDN transform options
ImageFormat, // 'avif' | 'webp' | 'auto'
FetchPriority, // 'high' | 'low' | 'auto'
PlaceholderType, // 'blur' | 'none'
CdnConfig // CDN configuration
} from '@7haven/h-image';
Works with any CDN that supports image transformations via query parameters:
// Example: Cloudflare R2
configureCdn({ baseUrl: 'https://cdn.7haven.online' });
Contributions are welcome! Here's how you can help:
MIT © 7Haven
Built with:
FAQs
Production-ready Svelte 5 image component with automatic AVIF/WebP optimization, zero layout shift, and type-safe API
We found that @7haven/h-image demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.