This cookies instance is read-only. To set cookies, you need to return a new Response using the Set-Cookie header.
app/api/route.ts import { cookies } from 'next/headers'
 
export async function GET(request: Request) {
  const cookieStore = cookies()
  const token = cookieStore.get('token')
 
  return new Response('Hello, Next.js!', {
    status: 200,
    headers: { 'Set-Cookie': `token=${token.value}` },
  })
}
Alternatively, you can use abstractions on top of the underlying Web APIs to read cookies (NextRequest):
app/api/route.ts import { type NextRequest } from 'next/server'
 
export async function GET(request: NextRequest) {
  const token = request.cookies.get('token')
}
Headers