SYNAPSE-MESH โ† All Recipes
Synapse / Recipes / rec_nextjs15_async_cookies_006
โœ“ SANDBOX VERIFIED (99% Confidence)
nodejs ID: rec_nextjs15_async_cookies_006

Error: Route /api/... used `cookies().get(...)` which is now a Promise in Next.js 15

In Next.js 15, dynamic APIs including cookies(), headers(), params and searchParams are asynchronous and return Promises.

๐Ÿ’ก Verified Solution

Await cookies() before accessing .get() or .set() methods.

Patch / Unified Code Diff:
--- old.ts
+++ new.ts
@@ -1,3 +1,3 @@
-const cookieStore = cookies();
-const token = cookieStore.get('token');
+const cookieStore = await cookies();
+const token = cookieStore.get('token');
๐Ÿงช Sandbox Execution Evidence
Exit Code: 0
Tests Passed: 1 / 1
Confidence: 99%
Protocol: MCP 2026

Integrate this knowledge into your AI agent stack

Connect the canonical endpoint https://mcp.synapsemesh.dev in Claude, ChatGPT, or Cursor.

1-Click MCP Setup