Connect to state with URL
Connect State with URL Hash
If you want to connect state of a store to URL hash, you can create your own hash storage.
Persist and Connect State with URL Parameters (Example: URL Query Parameters)
There are times when you want to conditionally connect the state to the URL.
This example depicts usage of the URL query parameters
while keeping it synced with another persistence implementation, like localstorage.
If you want the URL params to always populate, the conditional check on getUrlSearch() can be removed.
The implementation below will update the URL in place, without refresh, as the relevant states change.
When generating the URL from a component, you can call buildShareableUrl:
The generated URL would look like (here without any encoding, for readability):
https://localhost/search?fishAndBearsStore={"state":{"typesOfFish":["tilapia","salmon"],"numberOfBears":15},"version":0}}