paoloricciuti / sveltekit-search-params

The easiest way to read and WRITE from query parameters in sveltekit.
https://sveltekit-search-params.netlify.app
MIT License
478 stars 13 forks source link

What about Svelte 5? #79

Closed frederikhors closed 3 months ago

frederikhors commented 3 months ago

Are you working on a Svelte 5 version?

paoloricciuti commented 3 months ago

Hi, i'm not actively working on it since the page store in sveltekit will still be a store for the foreseeable future.

However i'm starting to think about how to convert to runes since it will probably involve some API redesign at least for queryParam since with runes it's not possible to return primitive values and you would be stuck to have something like this

<script>
    import { queryParam } from "sveltekit-search-params";

    const user = queryParam("user");
</script>

<input bind:value={user.value} />

which kinda defies the meaning where you can just use queryParameters like this

<script>
    import { queryParameters } from "sveltekit-search-params";

    const params = queryParameters({ user: true, });
</script>

<input bind:value={params.user} />

and have the same fine grained reactivity.

So either i would bump to v3 and remove queryParam or i'm thinking of some API like this

<script>
    import { queryParam } from "sveltekit-search-params";

    const [user, setUser, userInput] = $derived.by(queryParam("user"));
</script>

<input {...userInput} />

where you would use user to read the value, setUser to set it (maybe i can also do something like user("value") to set it) and userInput to spread it on an input to handle the update of a value from an input.

I will update this library to runes for sure tho.