I’ve stated the development of a web application a few weeks ago and its being very tricky to get things done with streamlit. It’s a great framework and what the team have achieved so far is great, but I feel it is not ready for web application development, yet.
The first hard thing I’ve found difficult to get done is this post theme: cookies. I am using CookieManager from extra-streamlit-components to store a cookie with user that I need in multiple parts of my application. The main problem here, for me, is that it works with javascript on the background (of course…) but it does not waits for the cookie to be set to continue execution. To workaround this, I’ve being putting some time.sleep() everytime I get or set cookies, not the ideal solution…
Another problem is for logout the user, because I had to delete the cookie with the user data on logout, but seems that the delete method of CookieManager is not working as expected, probably some bug from the library itself. To be specific, it stores the cookie in a dictinary and, when I call delete() method, it tries to delete the cookie from this dictionary, but it throws an error of “key not found”, with the key in the dictionary. To workaround this, instead of deleting the cookie, I am just setting its value to an empty dictionary.
It should work, and it does in my local environment, but for some reason, in production environment the cookie in logout() sometimes is set, sometimes it’s not, very weird behavior. With some debuging, I’ve found that it is related to some session_state settings I do right before setting the cookie, something like this:
def logout():
st.session_state[‘user_data’] = {}
st.session_state[‘auth_checked’] = False
self.cookie_manager.set(cookie_name=‘user’, data={})
If I comment the first two lines of logout() method, it works as expected. This problem I haven’t figured out how to solve yet.
For last, this web application has a very good and very beautifull UX design developed by one of my teammates. He did is using streamlit library components on Figma, but even so, getting the application to look exactly like the figma design is very, very tricky. I’ve being inspecting the HTML elements that stremalit components creates on the page and figuring out how to customize its style using the classes and attributes I’ve found on the specific HTML elements. Again, not the ideal. Despite of being very difficult, with some pacience I’ve managing to acomplish the expect result in terms of design, excepting customizing gaps between containers and columns, this one I haven’t found how to do.
Bottomline, with the little streamlilt experience and knowledge I have today, I wouldn’t start the project with it. I would go for a robust JS framework, probably Angular, using Materials for generic components. And for the back end I would go for anything: Nest.js, Laravel, Flask, Django, FastAPI, etc… For my case, where I am having a lot of work to customize streamlit components according to Figma design, it is not saving me development time as I thought it would in the begining, I feel it is actually giving me more work to do.