Shadcn Hooks

isBrowser

A library that checks if the code is running in a browser.

Installation

npx shadcn@latest add @hooks/is-browser
pnpm dlx shadcn@latest add @hooks/is-browser
yarn dlx shadcn@latest add @hooks/is-browser
bun x shadcn@latest add @hooks/is-browser

Copy and paste the following code into your project.

is-browser.ts
/**
 * A library that checks if the code is running in a browser.
 */
export const isBrowser = typeof window !== 'undefined'

Last updated on

On this page