![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
next-client-cookies
Advanced tools
Readme
Client cookies with support for SSR on the newest Next.js 13 (app directory).
SSR are client components that can be rendered both on the client and server side. Server components are server only components that can only be rendered on the server side. This library can support all 3 cases and will give you everything you need to work with cookies on the client and server side.
Please note that Next.js currently does NOT support updating cookies on Server Components (only on Actions or Routes are allowed to make changes to cookies within the server). If you need to update cookies on the server, please switch to a Client Component. Client components can be rendered on the server side (via SSR) and will support also updating cookies via special dehydration mechanism implemented by this library.
Interface and client side implementation based on the js-cookie package.
yarn add next-client-cookies
client only
component provider:'use client';
import { CookiesProvider } from 'next-client-cookies';
export const ClientCookiesProvider: typeof CookiesProvider = (props) => (
<CookiesProvider {...props} />
);
app/layout.tsx
file, add the CookiesProvider
:import { cookies } from 'next/headers';
import { ClientCookiesProvider } from './provider';
export default function RootLayout({ children }) {
return (
<ClientCookiesProvider value={cookies().getAll()}>
{children}
</ClientCookiesProvider>
);
}
This will work BOTH on the client and server side for SSR.
'use client';
import { useCookies } from 'next-client-cookies';
const MyComponent = () => {
const cookies = useCookies();
return (
<div>
<p>My cookie value: {cookies.get('my-cookie')}</p>
<button onClick={() => cookies.set('my-cookie', 'my-value')}>
Set cookie
</button>
{' | '}
<button onClick={() => cookies.delete('my-cookie')}>Delete cookie</button>
</div>
);
};
Will produce the same Cookies
interfaces using Next.js's cookies()
helper.
import { getCookies } from 'next-client-cookies/server';
const MyComponent = () => {
const cookies = getCookies();
return (
<div>
<p>My cookie value: {cookies.get('my-cookie')}</p>
</div>
);
};
MIT
FAQs
SSR and client support for Next.js v13 cookies (app directory)
The npm package next-client-cookies receives a total of 13,802 weekly downloads. As such, next-client-cookies popularity was classified as popular.
We found that next-client-cookies demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.