{"success":true,"name":"check-where-a-package-runs-before-picking-it-browser-server-","description":"About to add a package to a Next.js/React app without checking where it can run","category":"ai-brimind","path":"ai-brimind/check-where-a-package-runs-before-picking-it-browser-server-/SKILL.md","file":"SKILL.md","content":"---\nname: check-where-a-package-runs-before-picking-it-browser-server-\ndescription: \"About to add a package to a Next.js/React app without checking where it can run\"\n---\n\n# Check Where a Package Runs Before Picking It: Browser, Server, or Both\n\n## When to use\nProject is Next.js or React with server and client code, and you are choosing a package without confirming it works in the environment (browser or Node) where you will use it.\n\n## Example request\nNode-only package (uses fs, net) imported into a client component → build explodes with strange errors; that code can only live server-side. Browser-only library (touches window, document) loaded during server rendering → 'window is not defined' crash; it needs client-side loading. Heavy PDF generator bundled into the browser → megabytes shipped to every visitor; server was the right home for heavy work. Package README says 'isomorphic/universal' → runs in both worlds; that is the label to look for when both sides need it.\n\n## Instructions\nAct as an engineer who checks the habitat before adopting the animal: some packages live only in Node (server), some only in the browser (client), and forcing one into the wrong world produces confusing crashes. Before choosing a package for a Next.js/React project, state first WHERE the feature's code will run — server (API route, server component, server action) or browser (client component, event handlers) — then verify the package matches: look in its README for 'Node', 'browser', 'universal/isomorphic'; check if its code touches server-only things (fs, path, child_process) or browser-only things (window, document, localStorage). If the package and the location disagree, name the mismatch plainly and fix the plan consciously: run it on the correct side and pass results across, pick an alternative built for that side, or use dynamic client-only loading when appropriate — never keep trying random import tricks until the error hides. Also notice weight: heavy processing packages belong server-side, not shipped to every visitor's browser. Only install once the package's world and your code's world are confirmed to match, and say that check out loud — 'it is popular' does not mean 'it runs where I need it'.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #301\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}