What problem does it solve?
Provides structure and best practices for creating Streamlit applications with multiple pages, avoiding navigation conflicts and ensuring consistent state management across pages.
Core Features & Use Cases
- Consistent Navigation: Configure top or sidebar navigation with grouped sections or ungrouped pages for clear user flows.
- Shared and Page-specific State: Initialize global session state in the main module and use prefixed keys for page-specific state to prevent collisions.
- Conditional Pages & Access Control: Dynamically include or hide pages based on authentication, roles, feature flags, or environment conditions.
- Imports and Structure Guidance: Use a dedicated app_pages directory and root-level imports to prevent relative import issues.
- Use Case: Build an analytics dashboard with Home, Analytics, and Settings pages that share an API client and user session data while showing admin pages only to privileged users.
Quick Start
Create a streamlit_app.py that initializes shared session_state, defines navigation using app_pages entries with titles and icons, and calls page.run to render the selected page.