Initial UI Rendering Guide
Implementation patterns for the Initial UI rendering stage in the application bootstrap process.
Initial UI Rendering Guide
Overview
The Initial UI rendering stage is the second phase of the application bootstrap process, occurring immediately after the pre-ui completes. This crucial stage focuses on rendering the initial UI shell and providing immediate visual feedback to users while background initialization continues. This guide provides implementation patterns for effectively managing the Initial UI rendering stage.
Quick Start
To implement the Initial UI rendering stage:
-
Register tasks with the initializer:
-
Implement a conditional rendering pattern in your main component:
-
Create skeleton screens or loading placeholders that appear during this stage
When To Use
Add initialization tasks to the Initial UI stage when they:
- Involve UI rendering: Components and screens that make up the initial app shell
- Determine navigation flow: Logic that decides which screens to show based on auth state (using data from the pre-ui)
- Create loading indicators: Skeleton screens, progress indicators, and placeholders
- Set up navigation: Route configuration and navigation state initialization
The Initial UI stage should focus on tasks that create a responsive, interactive shell that users can see while more complex background operations complete in the background.
Implementation Patterns
As shown in the diagram, the Initial UI stage follows the pre-ui and transitions to the background once the initial user interface is rendered.
Navigation Integration
App Shell Rendering
The app shell provides the initial framework for your application:
Navigation Setup Based on Auth State
Configure navigation based on authentication state determined during Pre-UI:
Progressive Loading UI
Create adaptive loading screens that show real-time initialization progress:
Skeleton Screens for Content
Use skeleton screens to provide immediate visual structure while data loads:
Initial UI Stage Registration
Register the Initial UI stage initialization tasks:
Common Challenges
Navigation State Restoration
Properly restore navigation state during the Initial UI stage:
Handling Auth State Changes During Initial UI
React to authentication state changes during the Initial UI stage:
Transitioning Between Loading States
Create smooth transitions between different loading states:
Performance Considerations
-
(Do ✅) Prioritize perceived performance
- Show the UI shell as quickly as possible
- Use skeleton screens instead of spinners
- Animate transitions to mask loading times
-
(Do ✅) Defer non-essential UI elements
- Render critical navigation components first
- Use placeholders for content that requires data fetching
- Load complex UI elements progressively
-
(Don't ❌) Block the UI thread
- Avoid synchronous operations in render methods
- Keep initialization logic off the main thread
- Break up heavy operations into smaller chunks
-
(Do ✅) Measure and optimize render times
- Track time-to-interactive metrics
- Reduce component tree depth when possible
- Use React.memo and useMemo appropriately
Practical Examples
Auth-Aware Navigation Container
Feature-Specific Loading Strategy
Migration Considerations
When migrating from traditional loading approaches to our staged initialization pattern for Initial UI rendering, consider these helpful strategies:
From Global Loading States to Staged Loading
Many apps traditionally use a global loading pattern like this:
You can enhance this by:
- Separating UI rendering from data loading
- Using the
InitStage.INITIAL_UIfor navigation and essential UI setup - Deferring data fetching to the Background stage
- Implementing skeleton screens or placeholders during the transition
Progressive Enhancement Pattern
A good migration strategy involves progressive enhancement:
- First render the UI shell with skeleton placeholders during the Initial UI stage
- Then populate data gradually as Background tasks complete
- Finally, enable full interactivity after all initialization is complete
This approach significantly improves perceived performance compared to blocking renders until all data is available.
Component-Level Migration
You can migrate component by component:
This progressive approach lets you adopt the new initialization pattern one feature at a time.
Summary
The Initial UI rendering stage is focused on providing immediate visual feedback to users while the application continues to initialize background services. By following the patterns in this guide, you can create a smooth, responsive user experience from the moment your app launches.
Once the Initial UI stage completes, your app can proceed to the background for non-critical tasks, and finally the finalization to complete the initialization process.
Key principles to remember:
- Focus on perceived performance with immediate visual feedback
- Use skeleton screens and placeholders for content that's still loading
- Set up navigation and routing based on authentication state
- Register initialization tasks specific to UI rendering
- Create smooth transitions between loading and loaded states
Related Documents
Core Initialization Documentation
- App Initialization - Overview of the complete initialization architecture
- App Initialization Guides - Index of all initialization guides
Other Initialization Stages
- pre-ui - Stage before Initial UI rendering
- background - Next stage after Initial UI completion
- finalization - Final initialization stage
Related Implementation Guides
- navigation-system - Navigation system integration with initialization
- app-startup - Optimizing app startup performance
- skeleton-screens - Creating loading placeholders during initialization