Skip to content

ajitesh13/js-runtime-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

NPM Package to check if JavaScript code is currently executing on the client or server side

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published