---
source: https://iinventedlight.com/library/notes/nextjs-after.md
title: "Run work after a Next.js response with after()"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Next.js docs); CC-BY-4.0 (React docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Next.js docs, after; React docs, cache. MIT; CC-BY-4.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: Next.js after() and React cache"
tags: [nextjs, after, react, cache, server]
client: Librarian
sources:
  - id: S1
    title: "after"
    publisher: Next.js docs
    url: https://nextjs.org/docs/app/api-reference/functions/after
    accessed: 2026-11-19
    license: "MIT"
  - id: S2
    title: "cache"
    publisher: React docs
    url: https://react.dev/reference/react/cache
    accessed: 2026-11-19
    license: "CC-BY-4.0"
---
# Run work after a Next.js response with after()
**Answer:** `after()` from `next/server` lets you schedule work to be executed after a response (or prerender) is finished. That is useful for side effects that should not block the response, such as logging and analytics. React's `cache()` is a different tool: it caches the result of a data fetch or computation in Server Components.

## Where after() can run

It can be used in Server Components (including `generateMetadata`), Server Functions, Route Handlers, and Proxy. You pass a callback that runs after the response or prerender finishes. `after` is not a Request-time API. Calling it does not make a route dynamic. For a static page, the callback runs at build time or when the page is revalidated. The callback still runs if the response did not complete successfully.

## cache() for repeated work

`cache` is only for use with React Server Components. It lets you cache the result of a data fetch or computation. Use `cache()` for repeated work in one render. Use `after()` for work that should run after the response finishes.

| after() | cache() |
|---|---|
| after() | Runs a callback after the response or prerender |
| logging and analytics | Example side effects that should not block the response |
| cache() | Caches a fetch or computation in Server Components |
| Request-time API | after() is not one and does not force a dynamic route |

## See also

- [nextjs-route-handlers](https://iinventedlight.com/library/notes/nextjs-route-handlers/)
- [nextjs-caching-use-cache](https://iinventedlight.com/library/notes/nextjs-caching-use-cache/)
- [nextjs-server-and-client-components](https://iinventedlight.com/library/notes/nextjs-server-and-client-components/)

## Claims

- id: C1
  claim: after() schedules work to run after a response or prerender is finished.
  source: S1
  evidence: "after a response (or prerender) is finished"

- id: C2
  claim: Calling after() does not cause a route to become dynamic.
  source: S1
  evidence: "does not cause a route to become dynamic"

- id: C3
  claim: React cache() caches the result of a data fetch or computation in Server Components.
  source: S2
  evidence: "cache the result of a data fetch or computation"

## Sources

- [S1] after. Next.js docs. https://nextjs.org/docs/app/api-reference/functions/after . License: MIT. Accessed 2026-11-19.

- [S2] cache. React docs. https://react.dev/reference/react/cache . License: CC-BY-4.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Next.js docs, after; React docs, cache. MIT; CC-BY-4.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
