This component is an iframe wrapper that allows you to render an HTML iframe component and receive data posted using window.parent.postMessage
in the src
URL.
- Render an HTML iframe within a Streamlit app.
- Capture and return data posted from the iframe using
window.parent.postMessage
.
Install streamlit-iframe with pip
pip install streamlit-iframe
Use the component in your Streamlit app:
import streamlit as st
from streamlit_iframe import streamlit_iframe
event = streamlit_iframe({
"src": "https://www.example.com",
"height": "500px",
"width": "600px",
})
To set up the development environment, follow these steps:
-
Create a virtual environment:
python3 -m venv .venv source .venv/bin/activate
-
Install the required dependencies:
pip install streamlit
To run the example Streamlit app, use the following command:
streamlit run ./example.py