js-runtime-check
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

js-runtime-check

A simple utility function to determine if JavaScript code is currently executing on the client or server side.

Installation

Install via npm:

npm install js-runtime-check

Or via yarn:

yarn add js-runtime-check

Usage

import { isServer } from "js-runtime-check";

// Example usage
if (isServer()) {
  console.log("Code is running on the server side.");
} else {
  console.log("Code is running on the client side.");
}

API

isServer()

  • Returns: boolean - true if code is running on the server side, false if running on the client side.

Example

import { isServer } from "js-runtime-check";

if (isServer()) {
  // Code to execute on the server side
} else {
  // Code to execute on the client side
}

Contributing

Contributions are welcome! Please feel free to open issues or submit pull requests on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i js-runtime-check

Weekly Downloads

3

Version

1.0.2

License

ISC

Unpacked Size

5.18 kB

Total Files

7

Last publish

Collaborators

  • ajitesh13