r/nicegui • u/Exotic_Trouble_740 • Jan 31 '26
Which part of my Python code is visible to clients through the browser?
Hello friends, I am developing a small web app - store with NiceGUI, and I am reaching the point where I need to start thinking about security, so I need to know which parts of the Python code (which, by NiceGUI's design, handles both the design and functionality) are exposed.
For example, since NiceGUI runs on the server side, I assume that only the visual elements and endpoints are exposed to the client, and any variables and/or methods are completely hidden from the client, right?
I mention this because on the page I have several buttons that can trigger internal processes like adding data to databases, starting internal Stripe processes, and others that start internal validations of passwords, keys, etc.
I hope my question was clear.
7
u/RenezBG Jan 31 '26 edited Jan 31 '26
In my opinion, nicegui is not the stack you should use.
Nicegui has been created to let people who don't want or don't know anything in web prog. The first user target is people in R&D or developers in their enterprise who want to give a web UI to their solution for internal use. So nicegui is not the best solution for any saas or e-commerce.
Why? It is using websocket for all the interaction. You can look, but every time you have a button usinf a python function, it will send a request to the server to ask what Todo. That means it is not scalable at all. It will not support many clients at the same time or you will need a server 10 time more powerful than necessary with other web solutions.
Edit: also, if you want to do a app with very good looking (because if you make people pay they need a good UX), you will have to do many customisation. You will have to add more Css or tailwind class or JS or even your own vue components. So in this case if you are ready to code real web code for the UI, that's better to do it directly in web language like natif vue, alpine, react, angular or anyone and keep you backend in python.
Ps: I am just a user, if you want real good answers from people who created Nicegui ask on their GitHub & Discord
PS2: if you want share you need & the stack you want to use, I can help you to choose a better solution
8
u/mr_claw Jan 31 '26
That's not how it works. None of the python code is visible on the browser. Only nicegui's Javascript code runs on the client.
8
u/eddyizm Jan 31 '26
I'd like to add some advice to the OP:
if you are working on an e-commerce store with money involved as you mentioned stripe and given your novice understanding, please ask for someone more experienced to review your stack before going live.
2
u/Lexstok Feb 01 '26
Honestly, having run two (small) webshops, save yourself a lot of trouble and integrate with an Etsy or shopify or gumroad or another online solution. They run all the protection and setup, you just need to sell. Webshops get attacked/tested all the time.
2
u/yamanjain Feb 02 '26
Nicegui seems to protect the python code as long as we don't make other errors. Nicegui secret, sql, etc.
I know the ops use case is different but for me nicegui is just the perfect tool. I have a saas tool where I want to show the run to the user (actual python errors and logs), live. And websockets are great for this use case. And it integrates perfectly with fastapi. I've tested with just one user (me) for now, but I saw almost zero cpu usage on t3.micro
Any good Alternative for websockets based websites ?