#community-help

Creating Custom URL with SortBy Widget

TLDR Akash asked how to create a custom URL using the SortBy widget. Jason suggested setting routing: true to auto-update the URL for any widget type.

Powered by Struct AI
2
3w
Solved
Join the chat
Nov 08, 2023 (3 weeks ago)
Akash
Photo of md5-5a7e6fd9a070eac5034a6034f0dc38b1
Akash
01:34 PM
Kishore Nallan How can we create a custom URL using the sortBy widget? While we can create a URL from the refinement list, it seems that we can't do the same with the sortBy widget. How can we fix this?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:29 PM
You'd just need to set routing: true like this: https://github.com/typesense/showcase-xkcd-search/blob/1351a2cd879086d01d5c2d1be33e00d43b5e68a1/src/app.js#L132

And then Instantsearch will update the URL automatically for all types of widgets. Here's a demo with the sort by parameter in the URL:

https://findxkcd.com/?xkcd%5BsortBy%5D=xkcd%2Fsort%2FpublishDateTimestamp%3Aasc