Skip to main content

useIsCSR

Importing useIsCSR Hook​

import { useIsCSR } from '@ciceksepeti/cui-hooks';

Example​

import React from 'react';
import { useIsCSR } from '@ciceksepeti/cui-hooks';

export const Example = () => {
const isCSR = useIsCSR();
return (
<div>
{isCSR
? 'running in browser - client-side'
: 'not running in browser - server side'}
</div>
);
};

Preview​

PREVIEW
useIsCSR
  • Checks if page is being rendered at client-side or server-side
  • If returns true, it is client-side otherwise server-side
RESULT: Not running in browser - Server Side