Kvant library unifies state management across URL params, cookies, and localStorage
A new JavaScript library called kvantjs aims to eliminate repetitive boilerplate code that developers write when handling state across URL search params, cookies, localStorage, and sessionStorage. Each of these browser storage mechanisms has its own untyped API, forcing teams to manually handle JSON parsing, input validation, default values, and cross-tab sync on every project. Kvantjs replaces this scattered logic with a single type-safe API using a Zod-flavored schema builder, allowing developers to read and write state with a familiar useState-like hook. The library supports React, Next.js, Vue, Vue Router, and Nuxt, and automatically removes URL params when values match their defaults to keep URLs clean. It can be installed via npm and provides framework-specific adapters alongside hooks for storage and cookie management.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in