1. 3
    1. 5

      I would have liked to see an example or description of how the data is actually encoded.

      1. 2

        Good feedback, thanks. Added a demo video of an integration, an example of the encoded output, and some other details to the README.

      2. 3

        had a similar usecase, decided to use https://github.com/paoloricciuti/sveltekit-search-params

        	const bar = queryParam('f_bar', {
        		encode: (value: number[]) => Base64.encode(JSON.stringify(value)),
        		decode: (value: string | null) => {
        			if (!value) {
        				return [99]; // default
        			}
        			return [parseInt(JSON.parse(Base64.decode(value)))];
        		}
        	});
        

        will try this library next time, seems to solve nicely for things that are not too deeply nested. The part I like about the existing setup is I can use zod for validation etc.

        1. 1

          If it ain’t broke, don’t fix it, but if you do decide to try it out, URL State Codecs accepts user-defined value codecs that have a similar shape to what you have above. The only difference is that the return type would need to be wrapped in a Result object (similar to Zod’s safeParse() return type), which I recommend using with try/catch wherever errors are liable to occur.