TTC
Theo's Typesafe Cultshikishikichangchang

useRouter query

How do y'all handle typescript with nextjs's query params? Currently I'm doing
const cartId = query.cartId as string;
const cartId = query.cartId as string;
, but I'd rather not use the "as" keyword. query.cartId is of type string | string[] | undefined
C
cje332d ago
you can write a type guard, but honestly as is fine here