Streamlit requires every custom component call to have a unique key argument so it can track component state across reruns. streamlit_js_eval raises MarshallComponentException when key is omitted because Streamlit cannot marshall the component return value without an identifier.
Add key= to every streamlit_js_eval call. Each call on the same page must have a different key string.
from streamlit_js_eval import streamlit_js_eval
# Get user agent
user_agent = streamlit_js_eval(
js_expressions="navigator.userAgent",
key="get_user_agent"
)
# Get screen width (different key)
screen_width = streamlit_js_eval(
js_expressions="screen.width",
key="get_screen_width"
)