how to decod cookies on next in javascript

index.tsx
const cookieString = decodeURIComponent(document.cookie);
const cookiesArray = cookieString.split('; ');

const cookiesObject = cookiesArray.reduce((acc, cookie) => {
  const [name, value] = cookie.split('=');
  return { ...acc, [name]: value };
}, {});

console.log(cookiesObject);
283 chars
10 lines

related categories

gistlibby LogSnag