I\'m developping a JS-app that needs to work both on the client side and the server side (in Javascript on a browser and in Node.js), and I would like to be able to reuse th
There is an npm package just for this and it can be used both on client-side and server-side.
browser-or-node
You can use it this way
if (isBrowser) { // do browser only stuff } if (isNode) { // do node.js only stuff }
Disclaimer: I am the author of this package :)