Skip to content

feat(utils): add browser-safe runtime environment detection utility (#128) - #148

Merged
El-swaggerito merged 2 commits into
Axionvera:mainfrom
Code-Paragon:feat/128-env-detection
Jul 21, 2026
Merged

feat(utils): add browser-safe runtime environment detection utility (#128)#148
El-swaggerito merged 2 commits into
Axionvera:mainfrom
Code-Paragon:feat/128-env-detection

Conversation

@Code-Paragon

Copy link
Copy Markdown
Contributor

This PR resolves #128 by introducing a browser-safe runtime environment detection utility (isNode, isBrowser, isReactNative) that safely checks for execution contexts without triggering ReferenceErrors in cross-platform environments (Node, browser, or React Native).

Linked Issue

Closes #128

Type of Change

  • ✨ New Feature (minor)

Changes Made

  • src/utils/env.ts:
    • Implemented defensive environment checks (isNode, isBrowser, and isReactNative) guarding against undefined globals like process, window, document, and navigator.
  • src/utils/index.ts & src/index.ts:
    • Exported environment detection utilities from package root.
  • tests/env.test.ts:
    • Added unit tests verifying safe behavior across simulated Node, browser, and React Native runtimes using Vitest global stubs.
  • vitest.config.ts -> vitest.config.mts:
    • Renamed config to .mts for native ES module resolution on Windows.

Acceptance Criteria Checklist

  • An environment detection utility is added.
  • The utility works safely in Node, browser, and React Native-like contexts.
  • Tests cover expected runtime detection cases.
  • Documentation explains intended usage.

Checklist

image

@El-swaggerito

Copy link
Copy Markdown
Contributor

This PR cannot be merged automatically because it has merge conflicts and one or more workflow checks failed.

Please update the branch with the latest base branch, resolve the conflicts, and fix the failing workflow checks.

After the conflicts are resolved and checks pass, the automation can review it again.

@El-swaggerito
El-swaggerito merged commit c64c1b4 into Axionvera:main Jul 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add browser-safe environment detection utility

2 participants