#
@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="..."> (path-based variant segment, e.g. …/images/w_800,q_high,fmt_jpg/photo.jpg)
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 });
Path tokens are emitted in the recommended order (width, height, quality, fmt, fit, pos), matching the Image URL reference.
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.