state-in-url
Version:
Store state in URL as in object, types and structure are preserved, with TS validation. Same API as React.useState, wthout any hasssle or boilerplate. Next.js@14-15 and react-router@6-7.
12 lines (11 loc) • 427 B
TypeScript
import { type JSONCompatible } from "./utils";
export declare const subscribers: {
get(obj: JSONCompatible): Cb[];
add(obj: JSONCompatible, cb: Cb): () => void;
remove(obj: JSONCompatible, cb: Cb): void;
};
export declare const stateMap: {
get: <T extends JSONCompatible | undefined>(objKey: T) => T | undefined;
set: <T extends JSONCompatible>(objKey: T, value: T) => void;
};
export type Cb = () => void;