Type something to search...
API Reference for Next.js Functions and Hooks

API Reference for Next.js Functions and Hooks

Beyond file conventions and directives, the App Router exposes a substantial set of importable functions and hooks — the actual verbs of the framework, as opposed to the file-naming nouns covered elsewhere in the API Reference. This is the index page for that whole family: dozens of functions covering caching, navigation, request data, metadata generation, and more, most of which have their own dedicated, in-depth article elsewhere in this blog.

Why This List Is Worth Skimming Even If You Never Read It Top to Bottom

The value of this particular index isn't reading it start to finish — it's recognizing, at a glance, that a function you need probably already exists here before you reach for a workaround. A few groupings worth being aware of even before you need them:

Caching and revalidation: cacheLife, cacheTag, revalidatePath, revalidateTag, updateTag, unstable_cache, unstable_noStore — a cluster of functions covering both the newer Cache-Components-era caching model and the previous fetch-based one, depending on which model your project has adopted.

Request-time data access: cookies, headers, connection, draftMode, root-params, userAgent — the ways to reach into the incoming request from a Server Component, Route Handler, or Server Function.

Navigation and routing: redirect, permanentRedirect, notFound, forbidden, unauthorized, refresh, and the client-side hooks useRouter, usePathname, useParams, useSearchParams, useSelectedLayoutSegment(s), useLinkStatus, useOffline.

Metadata and image generation: generateMetadata, generateViewport, generateImageMetadata, generateSitemaps, generateStaticParams, and the ImageResponse constructor.

Error handling: catchError, working alongside the error.js file convention rather than replacing it, for component-level (not just route-segment-level) error recovery.

Deferred work: after, for scheduling work to run once a response has already been sent, without blocking that response.

Low-level request/response objects: NextRequest and NextResponse, the extended Web API types used throughout Route Handlers and Proxy.

The extended fetch: Next.js's own fetch function, extending the Web fetch API with caching and revalidation options baked directly into the call itself.

A Pattern Worth Noticing: Paired Functions

Several entries in this list only make sense in relation to a sibling function or file convention, and it's worth knowing the pairing exists before you go looking for "the other half":

  • forbidden() pairs with the forbidden.js file convention.
  • unauthorized() pairs with unauthorized.js.
  • notFound() pairs with not-found.js.
  • cacheTag() pairs with revalidateTag() and updateTag() — one tags a cache entry, the others invalidate by that tag.
  • cacheLife() works alongside the use cache directive, not standalone.
  • catchError() is the component-level, programmatic counterpart to the route-segment-scoped error.js file convention — the docs are explicit that you don't need to wrap an error.js default export in catchError, since error.js already gets a built-in boundary from Next.js itself.

Key Takeaways

CategoryRepresentative functions
Caching/revalidationcacheLife, cacheTag, revalidateTag, revalidatePath, updateTag
Request datacookies, headers, connection, draftMode
Navigationredirect, notFound, forbidden, unauthorized, useRouter, usePathname
Metadata/imagesgenerateMetadata, generateSitemaps, generateStaticParams, ImageResponse
Error handlingcatchError (component-level), paired with error.js (segment-level)
Deferred workafter

This list will keep growing as the framework does — treat it as a reference to search, not memorize, and check back here whenever you find yourself about to hand-roll something (deferred logging, tag-based cache invalidation, component-level error recovery) that a dedicated Next.js function might already solve more cleanly.

Tags :
Share :

Related Posts

Can Next.js Be Used with GraphQL?

Can Next.js Be Used with GraphQL?

Next.js and GraphQL are two powerful technologies that have gained significant traction in the web development community. Next.js, a React-based fram

Dive Deeper
How does Next.js differ from Create React App?

How does Next.js differ from Create React App?

In the world of modern web development, React.js has emerged as a dominant force due to its flexibility, performance, and extensive ecosystem. Two po

Dive Deeper
How does Next.js handle image optimization?

How does Next.js handle image optimization?

In modern web development, image optimization plays a critical role in enhancing user experience and improving site performance. Large, unoptimized i

Dive Deeper