guys, I’ve just made Cookies utility that compatible in Server Components, Client Components, and Server Actions 👀🔥
it just works with all Context in NextJS 13 appDir without problems🔥
first, we made an abstraction so that the Cookie utility between Server and Client has the same API.
then we create 2 different utilities between Server and Client with the BaseCookie blueprint that was created before.
in Cookie.server, it uses the default cookies utility from next/headers that only works on Server here is reference
in Cookie.client, we use js-cookie.
finally, the function that can bridge between Cookie.server and Cookie.client 🔥
-
but, why use
require()?
why not import statement? I don’t know, when i use import statement, i get error like this. -
why not dynamic import? Man, I want to use Cookies just synchronously without thinking about Promises 🤯
so, that is 🚀
this is auto generated content from ThreadsApp. see original at @gadingnst