Back to list

Unexpected Cookie Behavior in Next.js Server Components

5/10 Medium

The cookies() API allows type-checked usage like cookies().set() anywhere, but fails at runtime in certain contexts. This unexpected behavior differs from traditional request object access and creates developer footguns.

Category
compatibility
Workaround
partial
Stage
debug
Freshness
persistent
Scope
framework
Recurring
Yes

Sources

Collection History

Query: “What are the most common pain points with Next.js in 2025?3/27/2026

One common footgun is in how cookies are handled. You can call `cookies().set("key", "value")` anywhere and it will type-check, but in some cases it will fail at runtime.

Created: 3/27/2026Updated: 3/27/2026