Performance: Parallel routes concept
MEDIUM IMPACT
Parallel routes affect how quickly different parts of a page load and render by allowing multiple UI segments to load simultaneously.
// File structure: // app/dashboard/@main/page.tsx (MainContent) // app/dashboard/@sidebar/page.tsx (Sidebar) // app/dashboard/@footer/page.tsx (Footer) // app/dashboard/layout.tsx (below) import { ReactNode } from 'react'; export default function Layout({ main, sidebar, footer }: { main: ReactNode; sidebar: ReactNode; footer: ReactNode; }) { return ( <> {main} {sidebar} {footer} </> ); }
export default function Page() { return ( <> <MainContent /> <Sidebar /> <Footer /> </> ) }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Single route loading all UI | Single DOM tree with all nodes | Multiple reflows as components mount sequentially | Higher paint cost due to delayed rendering | [X] Bad |
| Parallel routes loading UI segments | Multiple smaller DOM trees loaded independently | Fewer reflows per route, can happen concurrently | Lower paint cost with faster visible content | [OK] Good |