Loading file and fallback
What you need to know
A loading.tsx file defines temporary route UI while the segment content is still being prepared. It supplies a framework-managed Suspense boundary for the page and descendants. A readable message or skeleton helps visitors understand that navigation is in progress.
By the end, you can: place loading UI at a segment; explain the fallback scope.
app/releases/loading.tsx
export default function Loading() { return <p role="status">Loading new releases...</p>;}Expected behavior (not framework-tested): The pending releases region can display this message while its page suspends. It is not a guarantee of a visible delay on every visit.
How it works
The same segment layout sits outside the automatic boundary. Its navigation can remain usable while the page is pending; if the layout itself waits for data, the fallback below it cannot cover that wait. Keep layouts inexpensive or introduce an explicit boundary around a slow child. A prefetched or already available page may resolve before a visitor sees the loading UI. The loading component receives no route props.
app/releases/page.tsx (local demonstration)
export const dynamic = "force-dynamic";export default async function Page() { await new Promise<void>(resolve => setTimeout(resolve, 600)); return <h1>New releases: Moss Garden</h1>;}Expected behavior (not framework-tested): With Cache Components disabled, this deliberately request-time page waits once for 600 ms. The framework may send the fallback before the heading. The actual display depends on buffering and navigation state.
Common mistake
Do not add an artificial delay to production just to make a skeleton visible. Use the fixture delay only to test pending and completion behavior; loading.tsx does not catch errors or automatically show during event-handler work.
Practice and verification
Add a link to /releases, navigate away before completion, then navigate again. Verify the final route remains correct and the shared navigation stays usable. Test warm visits separately.
Scope: App Router, proposed Next.js 16.x, Cache Components disabled for these labs. Snippets assume a reviewed TypeScript app and are static examples; framework behavior has not been executed. Exact supported patch and dependency set must be verified before running.
Further reading: Loading · Navigation