So, when you heard that NodeJS is not there, and we have built the entire application, keeping in mind that the NodeJS will be there, and a lot of power of NixJS framework that we have built in inside this application, so what kind of problem we've started facing or started chalking out where NodeJS was not there? As a developer, when we start between things like SSR, like server-side rendering, the dream of server-side rendering, and the hardware realities, what we figured it out, like, NixJS expects a server for things to run. And the kind of server that the customer given to us, it wanted basically static files. So, from the dream of using SSR, ISR, and all these things, to the fact that we have to use things like static files, some people will say, like, 90s, you know, you have just HTML, CSS, JavaScript, you don't have all these fancy things from framework anymore, that was, like, a little bit dream shattering for a tech team like us, like, which always want to work on some modern techs and all. So we figured out the constraints are basically this, no Node runtime, limited memory, this is second point. We were thinking that it will go to cloud, run on, like, you know, age, things will be super good, but now it is a tiny hardware, so you have the memory limitation, and also client came back with another thing, like, you have to do, you know, offline, so it should be served offline. It might not get the latest data when it is serving on offline, but of course, it should not break, it should not be a blank screen when somebody accessing this app on their iPad or somewhere. So our NixJS app suddenly couldn't render pages, because no Node.js, it could not run the API routes, no Node.js, and then the D3 charts that we have developed, it started choking, because there is no concept of GPU acceleration, you are using this hardware, no streaming APIs, we were dreaming to use that, and that started creating a lot of constraints for us. So as we understood, okay, this is what the life of this application, life of the developers without Node.js, let us start the investigation.
So we started the investigation, and there are two things, two paths that we realized that are there in front of us. One, rewrite everything that we have written in pure React spa mode, single page application mode, no more framework, because the power of NixJS itself, we are not able to use, right, so what is the use of using the framework? So let's get rid of that. Second thing, somehow make NixJS behave statically. Okay, we have spent our hard-earned time, you know, months on building server components, layouts, APIs based on various Node features, what to do, should we throw away and rewrite? We decided, okay, let's not throw away the implementation that we have done, let's try to dissect NixJS. Let's find out what parts of NixJS actually need Node.js, and if we can figure that out, maybe that portion of it needs some rewrite, but other portion we can keep it as it is, because we also have to deliver the customer, and to some extent, I admit that this was our mistake, probably we didn't understand the communication that where exactly this application is going to run, and that's one of the learning I want to call out towards the end, so I cannot really ask for too much of extra time to the customer that I have to rewrite this application, right?
So here are the findings. I'm going to go through them one by one very slowly. What we figured out, the SSR, server-side rendering, and we had written few API routes, those are Node-bound, because you need Node.js for making them work, hosting them, etc. The UI part, where it comes to the component, basically, can we export this component like HTML exports? If we can do that, that means at the end of the day, it is just a mere HTML, logic in JavaScript, and all the beautification is in style, and that is exported, that you can take it portable anywhere in the world, on any server, any application server. So that is good. So it means that if you can statically export the UI, I think that part is not dependent on Node or the Node-based server, great. Then the client components, we had a dream of using server components because since NixJS, 14, AppRouter, and then 15, the server components are everywhere, right? It is sold to all the developers. But as a developer, I think we always have the tendency of looking into that shiny, glowing piece, then too much putting our thoughts on whether that shiny thing is for me, do we really need that? So if you look into this application, the person of that application is someone who is going to go to check a lot of electric vehicles, they want to plug a device, a hardware to the battery, they want to collect the data, and on the iPad, they want to view certain things and take some calls. That's the person. Now, this person is never ever going to use this app publicly. It's not something that on a Google search, you should get this app, right? It's a very private app. So SEO is not at all a matter here, right? Why were we thinking about server components, server side rendering and all these things if SEO is not at all in picture? We can actually bring this app completely from the server side to the client component. And that works everywhere. You don't have the dependency. And if it is that way, we can easily export it and make it working on the browser, any browser. Then the last thing was about the ISR part, incremental static regeneration, where we didn't want the data that was shown on the UI to be still. After a certain period, the data should be refreshed, and users should be able to see the latest data on the app.
Comments