New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@react-corekit/use-where

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-corekit/use-where

Detects if the javascript is being loaded from a server (SSR) or a web client

latest
Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

@react-corekit/use-where

React Hook that detects if the javascript is being loaded from a server (SSR) or a web client

NPM JavaScript Style Guide

Install

npm install --save @react-corekit/use-where
yarn add @react-corekit/use-where

Syntax

const [isBrowser, isNode, isServer] = useWhere();

Returns

isBrowser

A function that detects if the code is being executed in a web browser.

isServer

A function that detects if the code is being executed in a server (SSR - Server side rendering).

isNode

A function that detects if the code is being executed in node environment (SSR - Server side rendering).

Usage

Visit: https://react-corekit.github.io/use-where/ for a minimalistic live demo

import React from "react";

import { useWhere } from "@react-corekit/use-where";

const App = () => {
  const [isBrowser, isNode, isServer] = useWhere();
  return (
    <div>
      <div>
        Is browser? <strong>{isBrowser() ? "Yes" : "No"}</strong>
      </div>
      <div>
        Is node? <strong>{isNode() ? "Yes" : "No"}</strong>
      </div>
      <div>
        Is server? <strong>{isServer() ? "Yes" : "No"}</strong>
      </div>
    </div>
  );
};
export default App;

Additional documentation

Node's Globals Documentation

Window Object Reference

React's ReactDomServer object Reference

License

MIT © glongh

Keywords

React

FAQs

Package last updated on 03 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts