Embedding dash into webpage

How are the dash dashboards embedded on the Dash by Plotly webpage

I see that it links to this heroku app but I don’t understand how it is put into the div.

Dash apps are simply hosted somewhere and then inserted using an <iframe>. You can see how the dash apps are inserted in our marketing page in this screenshot as an example.

1 Like

@charleyferrari, I now see where the <iframe> is defined. I was confused b/c I was looking at all the <div>'s that were inside. I never realized that all that code gets created when <iframe> is used.

I did know about the <iframe> method, but don’t think this would be ideal since my company would want to put this behind a paywall, AFAIK, people can just use the link to get access outside of the webpage. Are there any other methods that would achieve this?

I’ve read this post, but I’m using a javascript framework for the webapp.

I’d be very interested to know if it can be done without an IFrame or Django. It would be ideal to have analysts make the Dash app and give it to web developers who can embed it directly into a webpage without needing an IFrame

The other option is embedding it in a Flask app. See this page of the Dash User Guide.

Is there a particular reason why an iframe is not suitable?

From what I’ve seen, IFrames are generally bad practice. Sizing issues, passing on user permissions, styling, etc. They seem like a headache to work with if not 100% needed.

From what I know, Dash Deployment Server offers direct HMTL embedding and I am wondering if anyone knows a way to hack that same solution without having to make custom JavaScript UI elements that dash_core_components offers. If analysts/data scientists use Dash and web developers can embed them directly into the HTML, then proprietary content can be created from a strong analytical background and be shown on company websites that pass on all the security and user permissions needed from a production process

I’m afraid I can’t comment on the capabilities of Dash Deployment Server.

The challenge would seem to lie in the parent HTML app that you want to embed the Dash app in. I think this problem is better described as how to embed a React app in other arbitrary HTML. I found this answer on stack overflow, but using an iframe is clearly more straight forward.

Is it necessary to embed it in surrounding content? If not, then you can simply get the URL of the Dash app mounted at the relevant place on your domain, and style the Dash app so that it feels like another page on the site.

1 Like

Thanks @nedned, thats a great link. It just depends on which route is quicker to implement. The work needed to make the IFrame work means having to code dynamic sizing, passing user permissions through the IFrame, and styling your Dash app to match the web page. This could be just as much work as just embedding a React app, if not more, though I’ve never done either so I’m open to advice. If so the question now is:

Is there a way to get the Dash app in its native React.js code similar to how you can export a Python Plotly plot to JSON to be interpreted by JavaScript?

Not really. Dash apps are currently very much tied to the server-side component of the app. It may be possible at some point in the future to have Dash apps be fully clientside, with all local callbacks, but until then, you can’t really remove the server-side component.

In your situation, my intuition would be to attach the CSS stylesheet for the existing website to your Dash app and try to massage your Dash app’s layout to mirror the layout of the existing page (by setting the relevant class and ID names being targeted in the CSS etc). Then you can just mount your Dash app at a route alongside your existing app. I feel like that would involve the least amount of complexity.

three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online