Starting with version 5 of Netlify's Next.js Runtime (applicable for Next.js 13.5+), support for background and scheduled functions implemented as Next.js API Routes (a.k.a. Advanced API routes) is deprecated.
Instead, use regular background or scheduled Netlify Functions for the same purposes.
The main reason for dropping support is to improve robustness of the runtime: with v5, our goal is to simplify the runtime codebase as possible, and avoid adding or overriding functionality to built-in constructs of Next.js. This also allows us to focus on improving the core framework-agnostic features, which are applicable for all frameworks.
Here are annotated examples of advanced API routes and their framework-agnostic counterparts:
NOTE: Netlify background functions file or directory needs to end in -background
suffix.
If your scheduled or background functions require access to Next.js APIs (e.g. on-demand revalidation via revalidatePath
or revalidateTag
), you will need to create a Next.js API route / Route Handler that is called from your Netlify function and has access to these APIs.
The above examples both showcase this.