Skip to main content

Cookie gluon (SSR)

The cookie gluon is a gluon that is persisted in the cookies of the browser.

It is fully compatible with server side rendering, it's mean you can use the value of the gluon directly in your server side code and stayte will be able to hydrate the value from the cookies founded in the request headers.

warning

Actually, the only framework that is supported is next.js, but you can use it in any framework just by importing the component or the gluon only in the client side (no ssr) and also it's only working in dynamic rendering mode.

Usage

import { gluon } from "stayte";

const countGluon = gluon('count', {
from: 'cookie',
})

Demo

The cookie in the browser will be updated every time the button is clicked, the value will be persisted in the cookies, if you reload the page, the value will be restored from the cookies.

Extra methods

  • clear(): Clear the cookie