Next.js Discord

Discord Forum

Unable to fetch Next Cookies when opened from Whatsapp or any other social platform.

Unanswered
codingwizard12 posted this in #help-forum
Open in Discord
Hey guys, I have a nextJs application that accepts cookies from the browser header and render a server side/client side component based on the existence of the cookies. When I try to click on of its link from whatsapp or any other social platform. the server is not able to get the cookies and server side component is rendered, though The cookie exist in the mobile browser. what should I do?
export default function Layout({ children }: { children: React.ReactNode }) {
  const nextCookies = cookies();
  const abc = nextCookies.get('abc');
  if (!abc || !isTokenValid(abc.value)) {
    return <ServerWrapper>{children}</ServerWrapper>;
  }
  return <ClientWrapper>{children}</ClientWrapper>;
}
export const dynamic = 'force-dynamic';

0 Replies