Source: https://frameworkrecipes.dev/nextjs/

# Next.js: preserve requirements through advanced agent edits

Work through TypeScript examples of real application boundaries: Authorize a Next.js Server Action at the database write; Prevent private Next.js order responses from entering shared caches. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

[Download the Next.js rule pack ZIP](https://reporules.fyi/nextjs/rule-pack.zip) · [Inspect the YAML rules](https://reporules.fyi/nextjs/rules.yaml)

TypeScript

## [Authorize a Next.js Server Action at the database write](https://frameworkrecipes.dev/nextjs/server-action-ownership/)

A Server Action is a server entry point. Hiding a button or protecting a layout does not authorize the mutation itself. Put identity scope and current state in the conditional write so the action remains protected when called directly.

Broken edit flagged · corrected edit passes

TypeScript

## [Prevent private Next.js order responses from entering shared caches](https://frameworkrecipes.dev/nextjs/private-response-cache/)

Authorization can be correct while a shared cache serves the previous customer’s response to the next request. Explicit private, no-store headers express the boundary to browsers and intermediaries; the tenant-scoped query expresses it to the database.

Broken edit flagged · corrected edit passes

[Introductory framework example](https://frameworkrecipes.dev/nextjs/intro/)

## Use a correction as a saved requirement

Choose the failure you need to prevent, add the scoped rule to your repository, and check both the broken and corrected implementation. Ask your agent to inspect the finding, repair the code and recheck the same rule. Keep framework tests beside the model check.

Perch keeps the requirement beside the code. Reuse the named check during the agent’s next edit and in CI, with cached answers free on unchanged requests.

[Official Next.js documentation](https://nextjs.org/docs) · [All language and framework recipes](https://frameworkrecipes.dev/)

**Framework Recipes**

Implementation, failure path, check.

Published by Perch · © 2026 Verglas LLC. Framework Recipes is a Perch publication.

Perch’s MIT license covers the CLI; hosted model analysis is a paid service. Relevant source is sent to the configured model service.

[Perch CLI MIT license](https://github.com/lakeday-org/perch/blob/main/LICENSE) · [Article text](https://frameworkrecipes.dev/nextjs/index.md) · [Resource index](https://frameworkrecipes.dev/llms.txt)
