π₯οΈ Client Only
Learn how to run code exclusively in the browser environment using Toolkitify.
Sometimes you need to execute logic only in the browser and avoid running it during SSR (Server-Side Rendering) or in Node environments.
client-only ensures the code inside this module runs only in a client-side context.
This is useful when:
- Accessing the DOM
- Working with
window,document, or browser APIs - Applying visual UI changes
- Running analytics that require the browser
β Example
import "toolkitify/client-only";
// This will run only in the browser
console.log("This code runs only in the browser, not in Node/SSR");
// Browser API access is safe here
document.body.style.backgroundColor = "red";