# @fireimg/js

Vanilla JavaScript client for building optimized FireImg image URLs. Use it in any JS environment (browser or Node).

# Install

npm install @fireimg/js

# Usage

Create a FireImg client with your project (and optional base URL), then use getUrl, getSrcSet, or getSnappedUrl to build image URLs:

import { createFireimg } from '@fireimg/js';

const fireimg = createFireimg({
  project: 'your-project-id',
  baseUrl: 'https://img.fireimg.com',  // optional; defaults to https://i.fireimg.com
});

// Single URL for <img src="..."> using query parameters
const url = fireimg.getUrl('uploads/photo.jpg', { width: 800, quality: 'high' });

// Responsive srcset
const srcset = fireimg.getSrcSet('uploads/photo.jpg', { minWidth: 400, maxWidth: 1200, snapStep: 200 });

The CDN accepts query parameters for optimization. Supported names and aliases are: width/w, height/h, quality/q, position/pos, fit, format/fmt, and fill (see the Image URL reference).

getQueryUrl is now deprecated because getUrl returns the same query-parameter URL format.

Image options include width, height, quality, fmt, fit, pos, and for getSrcSet/getSnappedUrl: snapStep, minWidth, maxWidth. See the package README and types for full options.

# Links