0
0
Angularframework~10 mins

Pre-rendering static pages in Angular - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Pre-rendering static pages
Start Angular Build
Compile Components
Render Pages to HTML
Save Static HTML Files
Deploy Static Files
User Requests Page
Serve Pre-rendered HTML Instantly
Angular App Bootstraps (Optional)
Angular compiles components and renders pages to static HTML files before deployment, so users get fast, ready-to-view pages.
Execution Sample
Angular
ng run my-app:prerender

// Angular builds and pre-renders static HTML pages
// These pages are saved and served directly to users
This command triggers Angular to pre-render static pages during build.
Execution Table
StepActionInputOutputNotes
1Start buildAngular app source codeBuild process startsPrepare to compile components
2Compile componentsComponent templates and logicCompiled JS and HTMLReady for rendering
3Render pagesCompiled componentsStatic HTML pagesPages rendered as pure HTML
4Save filesStatic HTML pagesFiles saved in /dist/prerenderedReady for deployment
5DeployStatic filesFiles served by web serverNo server-side rendering needed
6User requests pageHTTP requestStatic HTML served instantlyFast load time
7Angular bootstrapsStatic HTML loadedAngular app starts (optional)Enables interactivity if needed
8EndPage servedUser sees fully rendered pageProcess complete
💡 All pages pre-rendered and served as static HTML, speeding up user experience.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
Build StateNot startedComponents compiledPages renderedFiles savedDeployed and served
Page ContentTemplate codeCompiled templateStatic HTMLStatic HTML fileUser sees HTML
User RequestNo requestNo requestNo requestNo requestRequest served instantly
Key Moments - 3 Insights
Why does Angular pre-render pages before deployment?
Pre-rendering creates static HTML so users get instant page loads without waiting for JavaScript to run, as shown in steps 3 and 6.
Does Angular still run in the browser after serving static pages?
Yes, optionally Angular bootstraps after serving static HTML to add interactivity, as seen in step 7.
What happens if a user requests a page not pre-rendered?
If not pre-rendered, the server may fallback to client-side rendering, which is slower; pre-rendering avoids this by having static HTML ready (step 4).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step are static HTML pages created?
AStep 3: Render pages
BStep 2: Compile components
CStep 5: Deploy
DStep 7: Angular bootstraps
💡 Hint
Check the 'Output' column in step 3 for when static HTML pages are generated.
According to the variable tracker, what is the state of 'Page Content' after step 4?
ATemplate code
BCompiled template
CStatic HTML file
DUser sees HTML
💡 Hint
Look at the 'Page Content' row under 'After Step 4' in the variable tracker.
If Angular did not bootstrap after serving static HTML, which step would be skipped?
AStep 6: User requests page
BStep 7: Angular bootstraps
CStep 3: Render pages
DStep 4: Save files
💡 Hint
Refer to the 'Action' column in the execution table for step 7.
Concept Snapshot
Pre-rendering static pages in Angular:
- Angular compiles components and renders pages to static HTML at build time.
- Static HTML files are saved and deployed.
- Users get instant page loads by serving these files.
- Angular can bootstrap afterward for interactivity.
- Improves performance and SEO by serving ready HTML.
Full Transcript
Pre-rendering static pages in Angular means the app builds and renders pages into static HTML files before deployment. This process starts with compiling components, then rendering pages to HTML, saving these files, and deploying them. When a user requests a page, the server serves the static HTML instantly, making the page load very fast. Optionally, Angular can start running in the browser afterward to add interactivity. This approach improves user experience by reducing wait times and helps search engines index pages better.