Skip to main content

Universal where possible, browser-only where necessary.

Utils-JS

A focused utility library for universal and browser-only JavaScript helpers

SSR-safe root APIBrowser-only helpersTyped utility modules
utils-js-example.ts
1import { generateUUID, sendData } from '@carry0987/utils';
2import { setLocalValue } from '@carry0987/utils/browser';
3
4const requestId = generateUUID();
5
6setLocalValue('request-id', requestId);
7
8const result = await sendData<{ message: string }>({
9 url: 'https://example.com/api/posts',
10 method: 'POST',
11 data: { requestId, published: true },
12});
13
14console.log(result.message);

What the library covers

Start with the root entrypoint, then opt into browser helpers only where the runtime allows it.

Clear Runtime Boundaries

Keep universal helpers in shared modules and move DOM-dependent logic to the dedicated browser entrypoint.

Useful APIs, Small Surface

Fetch wrappers, FormData helpers, equality checks, URL utilities, storage helpers, and event helpers are grouped by purpose instead of scattered through application code.

Built for Real Integration

The package supports direct imports, namespace imports, and explicit subpath entrypoints for modern bundlers and SSR applications.