DEV Community

Discussion on: How to connect your Client side to your Server Side Using Node and Express.

Collapse
 
trancephorm profile image
pyc • Edited

Feeling your frustration completely because I've gone through same frustration until I realised I need something like Parcel (parceljs.org/). Just go through Getting Started section and then you'll realise you can build apps using NPM modular system, and they will work in browsers because Parcel will pack them for that environment. Generally, as far as how I understand it's best is that you definitely separate client and server code into 2 projects. Parcel is optimizing client code, and Node.js is dealing with server code. Node.js as an environment has nothing to do with web browser clients which for example have DOM (Document Object Model) model which Node.js lacks.

I was foolishly trying to make IndexedDB work in Node.js, which is even (kind of) possible if you use fakeIndexedDB (github.com/dumbmatter/fakeIndexedDB), but that code works only on the server side, and by the way it's not a complete IndexedDB implementation in Node.js. You can't see that fake IndexedDB in your browser, it stores its data on Node.js's server memory.

Node.js server code serves only raw data in whatever format you want, web client uses it for obtaining data, but renders it however you want in the web browser.

All in all, it took some time for me to understand NPM (Node Package Manager) is actually completely independent or better say actually unrelated to Node.js.

Still I'm pretty new to all of this, and I would like someone to fix my view on this if I misunderstood it, but I doubt.