develop
useSSR
A custom hook to know where the code will be executed.
This hook returns whether the code is executed in the Server
(Server-Side-Rendering) or Client
side (Browser).
Usage
import { useSSR } from "@wonderflow/react-components";
export default () {
const { isBrowser, isServer } = useSsr();
return (
<div>
<p>{isBrowser ? 'Client' : 'Server'}</p>
<p>{isServer ? 'SSR' : 'Browser'}</p>
</div>)
}
Return value
VALUE
TYPE
DESCRIPTION
isBrowser
boolean
True when code runs Client side
isServer
boolean
True when code runs on the Server