An application shell is the UI that stays in place while route content changes. A header and navigation can remain mounted while a router replaces the contents of one main outlet. The shell is not the page for every URL: each valid route still needs a matching view. section 11.1.1 section 10.2
<body>
<app-header></app-header>
<nav>
<a href="/">Home</a>
<a href="/products">Products</a>
<a href="/settings">Settings</a>
</nav>
<main id="route-outlet"></main>
<app-footer></app-footer>
</body>
This HTML places persistent elements outside `#route-outlet`. Route rendering can replace the outlet without rebuilding the header, navigation, or footer. section 11.1.1
Keep responsibilities separate. The shell owns the layout and outlet; the router matches URLs and manages navigation; page components render their own content and load their own data. Pass a page plain inputs, such as a route parameter or an AbortSignal, rather than making every component depend on the router. section 11.5 section 11.1.6
A shell-based single-page application also needs a server contract:
- Return the entry HTML for valid app routes so a direct link can load the shell before client-side routing begins. section 10.2
- Do not rewrite assets or API endpoints as HTML. Return real 404 responses for unknown paths, and account for any deployment subpath in both server and client routing. section 10.2
A service worker can cache the shell’s HTML, CSS, core JavaScript, and other essential UI resources for offline access. Version that cache when its resource list changes and remove old versions. Keep cached request–response assets separate from domain records and drafts stored in IndexedDB. section 14.8.2 section 14.8.4
A route-level layout
A storefront can render its header once, then place the home, catalog, product, cart, checkout, or confirmation component in a single `<main id="route-outlet">`. Only the outlet contents change with the route. section 15.3
Choose the shell-only approach for its requirements, not as a default for every site. If public content must be discoverable and each URL should return meaningful HTML immediately, server-side rendering, static generation, or prerendering may fit better. section 10.2
