Skip to content

Integrating Nuqs with Local Storage #832

Answered by franky47
didemkkaslan asked this question in Q&A
Discussion options

You must be logged in to vote

If you're thinking of localStorage as the source of truth, and only want to populate it on mount from whatever is contained in the URL, you could do that in an effect.

Trying to synchronise localStorage updates back to the URL will cause issues, as localStorage is scoped to the whole browser, but URLs are scoped to a specific tab. Opening multiple tabs of the app with different URLs will cause conflicts.

Also, nuqs 2.3.0 introduced loaders, which you can use in an effect to parse location.search and avoid using reactive hooks (saving a few re-renders in the process).

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by franky47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants