legout/pi-config/building-streamlit-multipage-apps
Claude Code and agent skill by legout/pi-config
- community
Checking that the SKILL.md file is still in the repository.
Building multi-page Streamlit apps. Use when creating apps with multiple pages, setting up navigation, or managing state across pages.
Install
npx vskill@latest install legout/pi-config/building-streamlit-multipage-appsSKILL.md
The same SKILL.md was published earlier as legout/pi-config/building-streamlit-multipage-apps.
Streamlit multi-page apps
Structure and navigation for apps with multiple pages.
Directory structure
Important: Name your pages directory app_pages/ (not pages/). Using pages/ conflicts with Streamlit's old auto-discovery API and can cause unexpected behavior.
Main module
Note: When you handle titles in streamlit_app.py, individual pages should NOT use st.title again.
Navigation position
Few pages (3-7) → Top navigation:
Creates a clean horizontal menu. Great for simple apps. Sections are supported too—they appear as dropdowns in the top nav.
Many pages or nested sections → Sidebar:
Mixed: Some pages ungrouped:
Use an empty string key "" for pages that shouldn't be in a section. These ungrouped pages always appear first, before any named groups. Put all ungrouped pages in a single "" key:
Page modules
Global state
Initialize state in the main module only if it's needed across multiple pages:
Tip: Use st.session_state.setdefault("key", default_value) to initialize values only if they don't exist.
Why main module (for global state):
- Runs before every page
- Ensures state is initialized
- Single source of truth
Page-specific state
Use prefixed keys for page-specific state:
Share elements between pages
Put shared UI in the entrypoint (before page.run()) so it appears on all pages:
Programmatic navigation
Navigate to another page programmatically:
Create navigation links with st.page_link:
Note: Preferst.navigationoverst.page_linkfor standard navigation. Do not usest.page_linkto recreate the nav bar you get withst.navigation. Only usest.page_linkwhen linking to pages from somewhere other than the sidebar, or when building a more complex navigation menu.
Conditional pages
Show different pages based on user role, authentication, or any other condition by building the pages list dynamically:
Common conditions for showing/hiding pages:
st.user.is_logged_infor authenticated usersst.session_stateflags (roles, permissions, feature flags)- Environment variables or secrets
- Time-based access (e.g., beta features)
Imports from pages
When importing from page files in app_pages/, always import from the root directory perspective:
References
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinginstalled-skills/developing-with-streamlit/skills/building-streamlit-multipage-apps/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/legout/pi-config/building-streamlit-multipage-apps)