building-streamlit-multipage-apps

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

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/fangshine01/AI_agent --skill building-streamlit-multipage-apps-fangshine01
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: building-streamlit-multipage-apps
Source: https://github.com/fangshine01/AI_agent/tree/main/.github/skills/building-streamlit-multipage-apps
Command: npx skills add https://github.com/fangshine01/AI_agent --skill building-streamlit-multipage-apps-fangshine01

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a clear structure and navigation model for Streamlit applications that span multiple pages, removing common pitfalls like conflicting auto-discovery, fragmented state initialization, and duplicated UI elements.

Core Features & Use Cases

  • Structured multi-page layout: Prescribes a single entrypoint and an app_pages directory for predictable page discovery.
  • Navigation patterns: Shows how to use st.navigation for top or sidebar menus, grouped sections, and programmatic navigation with st.switch_page and st.page_link.
  • Shared and page-specific state: Recommends initializing shared session_state in the main module and using prefixed keys for page-local state.
  • Use Case: Build a dashboard with Home, Analytics, and Settings pages that share API clients and user context while allowing role-based conditional pages.

Quick Start

Run the Streamlit entrypoint from the project root ensuring pages live in app_pages, initialize shared session_state in streamlit_app.py, and define navigation with st.navigation before calling page.run().

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 multi-page Streamlit app with sidebar navigation?

Build a multi-page Streamlit app by defining an entrypoint that initializes shared session_state, placing pages in an app_pages directory, and configuring sidebar menus using st.navigation before calling page.run().

How does session_state work across pages in Streamlit multipage apps?

Session_state in Streamlit multipage apps works by initializing shared state centrally in the main entrypoint module, while page-specific state uses prefixed keys to prevent conflicts across different pages.

Can I use st.switch_page for programmatic navigation in a Streamlit dashboard?

Yes, you can use st.switch_page for programmatic navigation in a Streamlit dashboard to redirect users dynamically, alongside st.page_link for standard menu items and conditional role-based page access.

What is the best way to structure a large Streamlit multipage application?

The best way to structure a large Streamlit multipage application is using a single entrypoint file for centralized state initialization and an app_pages directory for predictable page discovery and shared UI elements.

Why does my Streamlit multipage app lose session state when switching pages?

Streamlit multipage apps lose session state when switching pages if state is initialized locally in page scripts instead of centrally in the main entrypoint, causing fragmented state resets on navigation.