2

I am posting this question in the lack of tutorials available for nwjs app development. Also, documentation in not much of a help. There are a few YouTube tutorials but they are 4-5 year old. Since then Node-webkit has changed into nwjs and now available in two different flavors. None of those tutorials are helping because they are based on old node-webkit and none of them answers any of my questions below. -

Let me break the title question into parts -

  1. Which version should I used for making nwjs based desktop app? Regular or SDK?
  2. How to make nwjs desktop app?
  3. What would be the app/folder structure?
  4. How to use node module with nwjs?
  5. How to make use of route in nwjs app? Or do I need route at all?

Question 1. Which version should I should of nwjs? Whatever I have read online, found that nwjs sdk is best bet because it allows to debug the app during development, which fairly answers my this question.

Question 2. How to make nwjs desktop app? I found another SOF post where one example has been given in an answer to create basic app - Here Though, example is pretty straight forward but I still have few confusion which I need clarification so I am gonna ask them in the next question below.

Question 3. What would be the ideal folder structure for nwjs app? I have this folder structure right now in my nodejs app.

**Main App

 |__app/

 |__backend/

     |__bigtable/

     |__pubsub/

 |__config/

     |__client.json

 |__models/

     |__database-models.js

 |__node_modules/

 |__public/

     |__css

     |__js

     |__img

     |__libs

 |__routes/

     |__auth-routes.js

     |__app-routes.js

     |__api-routes.js

 |__views/

     |__index.ejs

     |__login.ejs

 |__*.env

 |__package.json

 |__package-lock.json

 |__server.js

I don't know if can take this exact folder structure into nwjs, if yes? then How? if no, then how can I restructure my app for nwjs. What are the parts of the code that I need to restructure or redistribute or reintegrate in the app? As shown in the example in the above link server.js has been attached in the html file, why? What I have learned from developing nodejs app is that you need to run server.js and go to the localhost:port# in browser. This all had made me confused to develop nwjs app. Basically require doesn't work in browser but it does in nwjs

Question 4. How to use nodejs module in nwjs app? I know that nwjs creates its own local server and runs the app. You don't need to make express server or http server separately which runs on by default 8080 port. In the examples provided in the above link, uses express server which runs on 3000 port. Why do you need to create express server? Why can't we use default server which runs on 8080? Do I really need to use express module to use other nodejs modules (non-inbuilt modules)?

Question 5. Making use of routes in nwjs app? case 1 Let say if we can use default server then how can I utilize that to create routes to make front end interact with modules. case 2 Let say if we need express and we are attaching server.js into html file then do we need routes?

Extra I have also read that we can directly call node_modules from html then do we need express? do we need routes then? How can we secure code in nwjs? How can I package nwjs app for distribution with source code protection?

B L Λ C K
  • 600
  • 1
  • 8
  • 24

0 Answers0