Conditional redirection in Next.js

Viewed 22185

Is it possible to conditionally redirect a user to another Url based on cookie value? I know I can inspect cookie on a server & then redirect. But what should I do if a user came through Link. (I can't use Route.push because it's undefined on the server) Is there any way to use Router only on the browser?

I know at least one way to do this: to create simple button and add Router push & check cookies inside onClick handler, but is it a correct way to do this?

1 Answers
Related