@build-from-bits/browser-utils
v1.0.0
Published
Browser/environment utilities (URL helpers, media URL builders, SSR detection).
Readme
@build-from-bits/browser-utils
Browser/environment utilities: URL helpers, SSR detection, and media URL builders.
Install
npm install @build-from-bits/browser-utilsAPI
IN_SERVER—truewhenwindowis undefined (SSR/Node).getProtocol()—window.location.protocolornullon the server.getHostname()— host + port (example.com:8080) ornullon the server.getHostlink()—https://example.com:8080.getCurrentUrl()— full current URL ornullon the server.getUrlParameter(name)— query param value, or''when missing.isNoWindow()—truewhenwindowdoes not exist.getMediaUrl(baseUrl, key, options)— transformed media URL (h,w,f,q).getOriginalMediaUrl(baseUrl, key, extra)— untransformed media URL with optional extra params.
Usage
import { getHostlink, getUrlParameter, getMediaUrl } from '@build-from-bits/browser-utils';
const host = getHostlink();
const token = getUrlParameter('token');
const img = getMediaUrl('https://cdn.example.com/api/file/get', 'key-1', { w: 400, q: 80 });Publish
npm run build
npm run pack:check
npm run publish:npm
npm run publish:githubLicense
Licensed under the Apache License 2.0.
Copyright 2026 Build From Bits Pvt Ltd.
