Interestingly, I fed my project into Claude AI, and asked it if my web app specifically would benefit form my current approach or switching to Greg’s suggestion of a hybrid approach.
Claude AI’s response was that I should stick with current implementation for my web app (a “shell” page for static content, webcontainer subclass for dynamic content), because with my current approach, the active content webcontainers are just hidden, not closed/removed from memory (a side effect of having to navigate back and forth).
As a result, saving state is much simpler as it never goes away or has to be reloaded. State in my case refers to multiple complex forms, with session-peristent save for later review (rather than submit) and review of multiple looping videos where flashing is to be avoided.
I really did not expect this answer…
I generalised the question: when should I use one or the other and the answer is it depends on use case (of course). My approach is good for some stuff, not others. Detailed response from Claude AI below (may be of interest to some):
Read Claude AI's view on merits and trade-offs
Merits of Using Template Shell + WebContainers for Dynamic Content
This architecture pattern has significant advantages for certain types of web applications. Let me break down the key merits:
1. State Preservation
The Merit
WebContainers remain in memory when hidden, preserving their entire state automatically.
When This Matters
-
Complex forms with many fields (users navigate away and come back)
-
Multi-step processes where users might jump between steps
-
Draft functionality where work-in-progress needs to persist in the session
-
Undo/redo operations that rely on maintaining history
Example Scenarios
-
Survey applications where users review previous answers
-
E-commerce checkout with multiple steps
-
Document editors with multiple panels/views
-
Configuration wizards where users compare options across screens
2. Seamless Transitions
The Merit
No page reloads = no flashing, no loss of scroll position, no interruption of media or animations.
When This Matters
-
Media playback (audio/video/animations) that should continue across views
-
Real-time data (live charts, streaming data) that shouldn’t reset
-
Smooth UX where page flashes would feel jarring
-
Complex visualizations that take time to render
Example Scenarios
-
Media players with navigation sidebar
-
Real-time dashboards with multiple view modes
-
CAD/design applications with tool panels
-
Video conferencing with multiple screens
3. Controlled Navigation
The Merit
Complete programmatic control over navigation logic, history, and user flow.
When This Matters
-
Conditional navigation based on business rules
-
Preventing navigation to certain states (e.g., can’t go back after submission)
-
Custom history management (not just linear back/forward)
-
Workflow enforcement where users must complete steps in order
Example Scenarios
-
Testing/assessment platforms (can’t review answers after submission)
-
Banking transactions (can’t go back once confirmed)
-
Onboarding flows with branching logic
-
Medical diagnosis workflows with step dependencies
4. Shared Context & Components
The Merit
The shell provides persistent context (headers, footers, sidebars) that doesn’t reload.
When This Matters
-
Real-time notifications in a header that persist across views
-
Shopping cart indicators that update without page refresh
-
User presence indicators in collaboration apps
-
Global search that remains accessible and stateful
-
Persistent chat/help widgets
Example Scenarios
-
E-commerce sites with persistent cart display
-
Collaboration tools with presence indicators
-
SaaS apps with notification centers
-
Help desk systems with chat widgets
5. Performance Benefits
The Merit
Only the dynamic content area changes; shell elements stay in memory.
When This Matters
-
Complex headers/footers with heavy JavaScript/styling
-
Repeated navigation between views in a session
-
Resource-intensive components in the shell (maps, charts)
-
Reduced server requests (no need to re-fetch shell HTML)
Example Scenarios
-
Apps with complex navigation menus with mega-dropdowns
-
Dashboards with persistent data visualizations in sidebars
-
Maps applications where the map frame stays loaded
-
Admin panels with rich navigation trees
6. Simplified State Management
The Merit
Less need for explicit state serialization/deserialization across navigation.
When This Matters
-
Complex object graphs that are expensive to serialize
-
Temporary UI state (expanded accordions, scroll positions, selections)
-
Computed values that don’t need to be recalculated
-
Event handlers and timers that can continue running
Example Scenarios
-
Data grids with complex sorting/filtering/grouping state
-
File managers with selection state across folders
-
IDEs with open tabs and editor state
-
Project management tools with expanded/collapsed sections
7. Easier Testing & Debugging
The Merit
Navigation logic is centralized and programmatic, making it easier to test and debug.
When This Matters
-
Unit testing navigation flows without browser automation
-
Debugging navigation issues with clear entry/exit points
-
Logging navigation history for analytics or support
-
A/B testing different navigation patterns
When NOT to Use This Pattern
This architecture has trade-offs:
SEO Requirements
-
Search engines struggle with single-page apps
-
Each “page” doesn’t have a unique URL (without extra work)
-
Better alternative: Traditional multi-page with server-side rendering
Simple, Document-Based Sites
-
Blogs, marketing sites, documentation
-
No complex state to preserve
-
Better alternative: Standard page navigation or static site generators
Deep Linking Requirements
-
Users need to bookmark specific states
-
Sharing URLs to specific views
-
Mitigation: Requires hash-based routing or History API implementation
Memory Constraints
-
Many containers in history consume memory
-
Mobile devices with limited resources
-
Mitigation: Implement container disposal strategies
Browser Back/Forward Expectations
Ideal Use Cases Summary
This pattern excels for:
-
Single-page applications (SPAs) with complex workflows
-
Dashboard-style interfaces with multiple views
-
Media-centric applications (video, audio, streaming)
-
Data entry applications with extensive forms
-
Collaboration tools with real-time updates
-
Wizard/workflow applications with strict navigation rules
-
Testing/assessment platforms with non-rewindable flows
-
Tools and utilities (calculators, designers, editors)
Modern Web Context
This pattern in XOJO is conceptually similar to:
-
React Router with component-based routing
-
Vue Router with view components
-
Angular routing with lazy-loaded modules
-
Turbo/Hotwire partial page replacement
The shell + container pattern is essentially a component-based SPA architecture implemented in XOJO Web, and it brings the same benefits (and challenges) as modern JavaScript SPA frameworks.
Bottom line: Use this pattern when you need rich, stateful, application-like behavior in the browser. Use traditional page-based navigation when you need SEO, deep linking, or are building document-centric sites.