Function decorator to store singleton objects.
Function signature

st.singleton(func: Optional[function] = None, show_spinner: bool = True, suppress_st_warning=False)


func (callable)

The function that creates the singleton. Streamlit hashes the function's source code.

show_spinner (boolean)

Enable the spinner. Default is True to show a spinner when there is a "cache miss" and the singleton is being created.

suppress_st_warning (boolean)

Suppress warnings about calling Streamlit functions from within the singleton function.

Was this page helpful?


Still have questions?

Our forums are full of helpful information and Streamlit experts.