isBrowser
A library that checks if the code is running in a browser.
Installation
npx shadcn@latest add "https://shadcn-hooks.vercel.app/r/is-browser.json"pnpm dlx shadcn@latest add "https://shadcn-hooks.vercel.app/r/is-browser.json"yarn dlx shadcn@latest add "https://shadcn-hooks.vercel.app/r/is-browser.json"bun x shadcn@latest add "https://shadcn-hooks.vercel.app/r/is-browser.json"Copy and paste the following code into your project.
/**
* A library that checks if the code is running in a browser.
*/
export const isBrowser = typeof window !== 'undefined'Last updated on