When to use secrets.toml vs dotenv?

Does anyone have any wisdom on when to use secrets.toml file vs .env file (python-dotenv)?

Hello,

If you’re using Streamlit Community Cloud, I recommend using secrets.toml and st.secrets. This approach simplifies setup and avoids storing sensitive information in your Git repository.

However, for local projects or if you’re not using Community Cloud, secrets.toml isn’t strictly necessary. You can manage your secrets in a way that best suits your specific needs.

2 Likes