git-agent for Next.jsgit-agent understands Next.js routing conventions, Server Actions, API routes, and middleware, producing atomic conventional commits that accurately reflect your Next.js-specific changes.
diff --git a/app/api/revalidate/route.ts b/app/api/revalidate/route.ts
index new file mode 100644
--- /dev/null
+++ b/app/api/revalidate/route.ts
@@ -0,0 +1,22 @@
+import { revalidatePath } from "next/cache";
+import { NextRequest, NextResponse } from "next/server";
+
+const SECRET = process.env.REVALIDATION_SECRET;
+
+export async function POST(req: NextRequest) {
+ const { secret, path } = await req.json();
+
+ if (!SECRET || secret !== SECRET) {
+ return NextResponse.json({ error: "unauthorized" }, { status: 401 });
+ }
+
+ if (!path || typeof path !== "string") {
+ return NextResponse.json({ error: "path required" }, { status: 400 });
+ }
+
+ revalidatePath(path);
+ return NextResponse.json({ revalidated: true, path });
+}feat(api): add on-demand revalidation endpoint for ISR paths
- implement POST /api/revalidate secured by REVALIDATION_SECRET env var
- validate path param before calling revalidatePath to avoid silent no-ops
- return structured JSON for both success and error cases
Allows the CMS webhook to trigger cache purges for specific pages without
a full rebuild; secret validation prevents unauthorised cache busting.brew install gitagenthq/tap/git-agent
# inside your Next.js project
git-agent init # detects app/ or pages/ layout and suggests route scopesDoes git-agent understand Next.js dynamic route segments?How does git-agent handle changes to both layout.tsx and page.tsx?Can git-agent commit my Server Actions separately from UI components?