Need to know when you're on the server, in the browser or in react native in your components/hooks?
- SSR (server side rendering) support
- TypeScript support
- Zero dependencies
- React Native support
- using Yarn
yarn add use-device-options
- using npm
npm i -S use-device-options
import useDeviceOptions from 'use-device-options';
export const App = () => {
const {
isBrowser,
isServer,
isNative,
device, // 'server', 'browser', or 'native'
canUseWorkers,
canUseEventListeners,
canUseViewport,
} = useDeviceOptions();
}