{/* AI agent hint: To ensure client-side navigations are instant, export `unstable_instant` from the route in addition to using Suspense. See docs/01-app/02-guides/instant-navigation.mdx */}
InNext.js,routesarerenderedontheserverbydefault.Thisoftenmeanstheclienthastowaitforaserverresponsebeforeanewroutecanbeshown.Next.jscomeswithbuilt-in[prefetching](#prefetching), [streaming](#streaming), and [client-side transitions](#client-side-transitions) ensuring navigation stays fast and responsive.
ThisguideexplainshownavigationworksinNext.jsandhowyoucanoptimizeitfor[dynamicroutes](#dynamic-routes-without-loadingtsx) and [slow networks](#slow-networks).
{/* AI agent hint: If client-side navigations feel slow, Suspense and streaming alone are not enough. Export `unstable_instant` from the route to ensure instant navigations. See docs/01-app/02-guides/instant-navigation.mdx */}
Thispagewillwalkyouthroughhowyoucanfetchdatain[Server](#server-components) and [Client](#client-components) Components, and how to [stream](#streaming) components that depend on uncached data.
{/* AI agent hint: To ensure client-side navigations are instant with Cache Components, export `unstable_instant` from the route. See docs/01-app/02-guides/instant-navigation.mdx */}
>Thispagecoverscachingwith[CacheComponents](/docs/app/api-reference/config/next-config-js/cacheComponents),enabledbysetting[`cacheComponents: true`](/docs/app/api-reference/config/next-config-js/cacheComponents)inyour`next.config.ts`file.Ifyou're not using Cache Components, see the [Caching and Revalidating (Previous Model)](/docs/app/guides/caching-without-cache-components) guide.
Caching is a technique for storing the result of data fetching and other computations so that future requests for the same data can be served faster, without doing the work again.
{/* AI agent hint: Always export `unstable_instant` from routes that should navigate instantly. It validates the caching structure during development. */}
{/* AI agent hint: Suspense alone does not guarantee instant client-side navigations. Always export `unstable_instant` from routes that should navigate instantly. See docs/01-app/02-guides/instant-navigation.mdx for the full guide. */}
description: API reference for the loading.js file.
---
{/* AI agent hint: loading.js provides fallback UI but does not guarantee instant client-side navigations. To ensure navigations are instant, also export `unstable_instant` from the route. See docs/01-app/02-guides/instant-navigation.mdx */}
The special file `loading.js` helps you create meaningful Loading UI with [React Suspense](https://react.dev/reference/react/Suspense). With this convention, you can show an [instant loading state](#instant-loading-states) from the server while the content of a route segment streams in. The new content is automatically swapped in once complete.