"Exporting" Streamlit App to Javascript/Typescript App

Hi Streamlit Community,

So far at my company weā€™ve really enjoyed using Streamlit to quickly stand up interactive data viz dashboards. Now that weā€™ve been able to iterate through ideas in order to reach a satisfactory initial dashboard, itā€™s time to productionize itā€“the only problem is that our entire front end is in JS/TS, no Python allowed. My team only does Python, and weā€™ll have limited support from our front end team. (Iā€™ve gone through the React ā€œtic-tac-toeā€ tutorial, so just enough to generally understand how components work).

Iā€™ve seen plenty of topics related to getting JS/TS into Streamlit (ā€œuse custom componentsā€), but nothing about the reverse. Now that Iā€™ve got a Streamlit dashboard, what would be the best way to display it through a javascript front end? Obviously any of my data processing that currently takes place in Python will need to be converted manually, but maybe I can easily extract the componentsā€™ React code to place into our JS app?

Thanks in advance for any help

Hello @jsuser , welcome to the community! :slight_smile:

but maybe I can easily extract the componentsā€™ React code to place into our JS app?

My very honest short answer: It is theoretically possible but the cost/benefit ratio is probably too high. But let me dive in a little bit more


Answer 1: the JS team probably has its preferred tools: if youā€™re prototyping in Streamlit then productionizing in JS/TS because you donā€™t have processes nor resources in your company to monitor/support/allow Python applications in production (which I understand, I am in the same boat), then your frontend team probably has its preferred frontend tooling (like maybe they prefer Vue.js over React which is what Streamlit is built with) to build projects and will use your Streamlit app as a design mockup to build the final product, so I wouldnā€™t try to extract the React components from Streamlit and let them work on it for replicating your app for 3 months with their favorite tools.

Answer 2: it is possible to read the React components source code: if you really want the same look & feel, you can check out the Streamlit source code and let the JS team try their best extracting the relevant code for each component :confused: doable but a bit hard since itā€™s not a totally separate React component library and there may be a bit of logic youā€™ll have to unwire from the component. But doable (though I canā€™t tell how much time they would take)

My personal answer is recreating a TS app out of a Streamlit app is contrary to the Streamlit philosophy: hereā€™s my favorite slide from Adrien Treuille talk introducing Streamlit in 1/4: What is Streamlit - YouTube

If you watch the talk, my personal opinion is Streamlit was created exactly for the purpose of ā€œWe have a Python team building a lot of valuable webapps to solve problems and we donā€™t want to rely on the availability of a JS team to rewrite and support them in small production scopesā€, and the reason thereā€™s no doc for Streamlit to JS/TS app is because it goes against this philosophy. You want to be able to use Streamlit/Dash/Panel/Django/any Python web framework in production without having to convert them to a full TS app.

Maybe this is an opportunity for you and Python team to ponder if you want to move more Python apps into production. Perhaps you can use Streamlit as a demo to explain to other JS colleagues how you would work together in producing value, and rethink the ā€œno Python allowed in productionā€ part of your company, so you can experiment deploying Python in production.

As a compromise maybe you can host your Streamlit app in a Docker container/on the Streamlit Cloud for example so the production team donā€™t have to maintain a Python install, and then maybe you can iframe the Streamlit frontend inside your JS product?


There are unfortunately no easy solutions for this one from my point of view, but I do hope you manage to start talking about the ā€œno Python in prodā€ change at the very least.

Have a nice day :balloon:
Fanilo

5 Likes

Thanks for the detailed answer andfanilo! I suspected this might be the case. Some combination of Answer 1 and Answer 2 is likely what weā€™ll have to do, the balance of which will need to be left to the JS team.

The ā€œno Python in prodā€ thing unfortunately has more to do with keeping things consistent from the perspective of our users rather than anything explicitly engineering-related. It wouldnā€™t make sense for them to interact with an app full of custom TS-/React-based pages/dashboards/visualizations, and then to be suddenly confronted with a very different looking Streamlit dashboard with matplotlib or other python-generated graphics. So unfortunately I think that obviates the iframe solution as well, though it is an interesting idea, hopefully someone else will be able to read this thread in the future and use it :slight_smile:

Thanks again!

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.