Functions
after: Post-response work
Schedule noncritical work after the response or prerender completes. In a Route Handler, capture safe values before scheduling work; the callback is not a durable job queue. The host must support the post-response lifetime, and the route duration budget still matters. During static generation the callback may run at build time. Example context: Next.js 16.x documentation lane; illustrative snippet or file tree, not executed. Exact candidate patch 16.4.6 remains unverified. Expected behavior / verification: Expected JSON is {"count":2}; inspect the sanitized server log separately. Restart a disposable host before a durable job would finish: do not infer delivery guarantees from a log.
Formal Syntax & Structure
nextjs syntaxnextjs
after(callback)Working Example
Example Snippetnextjs
import { after } from 'next/server';export function GET() { after(() => console.info('catalog response completed')); return Response.json({ count: 2 });}