Package Exports
- js-runtime-check
- js-runtime-check/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-runtime-check) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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-checkOr via yarn:
yarn add js-runtime-checkUsage
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-trueif code is running on the server side,falseif 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.