moshest / next-client-cookies

SSR and client support for cookies in Next.js 13 (app directory)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Missing <CookiesProvider>

jexroid opened this issue · comments

Hi Moshest, thanks for your awesome package, i have a wired error in my nextjs 14 logs and the package is working perfectly and i can see the cookie in client side but i have this error in my server side:

⨯ node_modules\next-client-cookies\dist\hook.js (44:12) @ eval
 ⨯ Error: Missing <CookiesProvider>
    at Form_handler (./app/components/ai/form_handler.tsx:21:84)

here is my code:

"use client";

import { useCookies } from 'next-client-cookies';


export function Form_handler() {
  const cookies = useCookies();
  const my_token = cookies.get('token')
  console.log(my_token)


  


  return (
    <section className="flex justify-center">
      <div>nothing</div>
    </section>
  );
}

export default Form_handler;

Please make sure you added <CookiesProvider> to the root layout file.. it seems that it's missing.