Routing
By default FindkitUI saves the current search terms and the possible group to the URL Query String using the browser History API so user can come back to the search results using the back button and keep the search terms after a page refresh.
Unfortunately not all frameworks play well with the query string modification.
Alternatively the terms can be saved to the url hash eg. after the #
character
or kept completely in memory.
The change the behaviour set the router
option:
const ui = new FindkitUI({
publicToken: "<TOKEN>",
router: "hash", // or "memory"
});
Custom Router
The router backend can be also completely customized by passing in custom RouterBackend implementation.
TODO: full example of the custom backend usage
Reserved URL-parameters
Because Findkit state is stored in URL, the param keys need to be unambiguous. Because there can be one or more Findkits in a page this is also true between instances.
Findkit reserves these query parameters:
- Default search key,
instanceId + separator + q
, e.g.fdk_q
in?fdk_q=test
- Default group key,
instanceId + separator + id
e.g.fdk_id
in?fdk_q=test&fdk_id=group1
- Default custom router data prefix,
instanceId + separator + c + separator
e.g.fdk_c_
in?fdk_q=test&fdk_c_mykey=foo
- searchKey, if passed
- groupKey, if passed
- customRouterDataPrefix, if passed
When a key is reserved, it cannot clash with another reserved key in the same Findkit instance or any other Findkit instance on the page. Reserved keys function the same way with all routing options.