Skip to main content

Query gluon (SSR)

The query gluon is a gluon that is persisted in the query string of the url.

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 query string on the client side.

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: 'query',
defaultValue: 10
})

Demo

The url will be updated every time the button is clicked, the value will be persisted in the query string, if you reload the page, the value will be restored from the query string.

Extra methods

  • clear(): Clear the query strign