Using cookies on first client component render
Unanswered
Cape lion posted this in #help-forum
Cape lionOP
I'm wanting to store certain data in cookies, which I would then use to render a client component.
E.g. query params could be stored in cookies, and then loaded and used to view a table using specific criteria.
So far, I have not found a way to be able to do this until after the first page render. This causes the data in the table to show one set of data, and then immediately load the query params in a useEffect, and reload the table for the second render. This is visually jarring, and seems it should be unnecessary in the first place.
tl;dr Is there a way I could load cookies in a client component for a first render, and update those cookies from the client component?
E.g. query params could be stored in cookies, and then loaded and used to view a table using specific criteria.
So far, I have not found a way to be able to do this until after the first page render. This causes the data in the table to show one set of data, and then immediately load the query params in a useEffect, and reload the table for the second render. This is visually jarring, and seems it should be unnecessary in the first place.
tl;dr Is there a way I could load cookies in a client component for a first render, and update those cookies from the client component?
1 Reply
Cape lionOP
Ended up using the
next-client-cookies library and it handled everything very nicely