Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
cant read cookie in nextjs ssr

I have a problem with read a cookie in my browser.. here's my code

const dataA = authService.isLogin();

useEffect(() => {
  if (dataA) {
     router.push("/");
  }
}, [dataA]); ```

the dataA is get a cookie value from my browser.. but thats not working.. it caused my router.push not redirect to the page

how can i solve it ?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should move dataA into useEffect hook because dataA run in SSR not browser so that can't read cookie from browser. Try like this:

useEffect(() => {
  const dataA = authService.isLogin();
  if (dataA) {
     router.push("/");
  }
}, [dataA]); 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!