building-streamlit-multipage-apps

Build multi-page Streamlit apps with st.navigation and shared session state.

1|1|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/Shamrock2245/shamrock-trading-bot --skill building-streamlit-multipage-apps-shamrock2245
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: building-streamlit-multipage-apps
Source: https://github.com/Shamrock2245/shamrock-trading-bot/tree/main/.agent/skills/developing-with-streamlit/skills/building-streamlit-multipage-apps
Command: npx skills add https://github.com/Shamrock2245/shamrock-trading-bot --skill building-streamlit-multipage-apps-shamrock2245

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Managing navigation, shared session state, and modular page organization across multiple Streamlit pages can be error-prone and lead to duplicated UI, inconsistent state initialization, and brittle imports; this Skill provides clear structure and patterns to avoid those pitfalls.

Core Features & Use Cases

  • Entrypoint pattern: Centralized streamlit_app.py that initializes shared state, defines navigation, and runs the selected page so page modules remain focused on content.
  • Navigation strategies: Guidance for top navigation for small apps and sidebar or grouped navigation for many pages, including mixed ungrouped sections.
  • State management: Best practices for initializing global session state in the main module and using prefixed keys for page-specific state to avoid collisions.
  • Programmatic flows: Examples for switching pages programmatically, building conditional page lists (auth, roles, feature flags), and safe import conventions for page modules.
  • Use Case: Ideal for developers building dashboards, admin consoles, or analytics tools that require consistent navigation, shared widgets, and modular page code.

Quick Start

Create a streamlit_app.py entrypoint that initializes needed st.session_state keys, constructs a st.navigation over an app_pages directory (home, analytics, settings), displays shared UI like the title, and calls page.run() to render the selected page.

Frequently Asked Questions about building-streamlit-multipage-apps

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a multipage Streamlit app with centralized navigation?

Build a multipage Streamlit app by creating a centralized streamlit_app.py entrypoint that initializes shared session state, defines navigation using st.navigation, and runs selected page modules. Page modules remain focused on content while the entrypoint handles routing and shared UI state.

How does session_state management work across multiple Streamlit pages?

Session_state management across Streamlit pages requires initializing global keys in the main entrypoint module and using prefixed keys for page-specific state to avoid collisions. This pattern ensures consistent state initialization and prevents duplicated UI or brittle imports across pages.

What's the best way to organize page modules in a Streamlit multipage app?

Organize Streamlit multipage page modules by creating a dedicated app_pages directory structure. The main streamlit_app.py entrypoint constructs navigation over this directory, keeping page code modular and focused on content while the entrypoint handles shared widgets and routing.

Can I switch Streamlit pages programmatically based on user authentication?

Switch Streamlit pages programmatically using st.switch_page, which supports building conditional page lists based on authentication, user roles, or feature flags. This enables dynamic navigation control where available pages change based on application state or permissions.

When should I use top navigation versus sidebar navigation in Streamlit?

Use top navigation in Streamlit for small apps with few pages, and sidebar or grouped navigation for apps with many pages. Mixed ungrouped sections are also supported, allowing flexible navigation strategies that scale with application complexity.

Do I need a single entrypoint file to manage navigation in Streamlit multipage apps?

A single entrypoint file like streamlit_app.py is needed to manage navigation in Streamlit multipage apps. It centralizes session_state initialization, defines the navigation structure, displays shared UI like titles, and calls page.run() to render the selected page module.