# Integrating Search UI with NextJS Router Dynamic Routes

**URL:** <https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [December 31, 2022, 9:19pm UTC](https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248 "2022-12-31T21:19:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lew\_Ashby](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lew_ashby/32/79866_2.png) [@Lew\_Ashby](https://discuss.elastic.co/u/Lew_Ashby)\
**Post date:** [December 31, 2022, 9:19pm UTC](https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248/1 "2022-12-31T21:19:32Z")

</div>

I'm using the steps written in [NextJS Integration](https://docs.elastic.co/search-ui/guides/nextjs-integration) , when integrating Search UI with NextJS Router, I'm having troubles in the case I have dynamic routes, ie. /seller/[id], then when activating some Facets, the url get lost, instead of writing /seller/12 for id=12 writes /seller/[id]

---

<div class="post-metadata">

**Author:** ![joemcelroy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joemcelroy/32/103757_2.png) [@joemcelroy](https://discuss.elastic.co/u/joemcelroy)\
**Post date:** [January 3, 2023, 12:36pm UTC](https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248/2 "2023-01-03T12:36:04Z")

</div>

Hi @Lew_Ashby,

Could you clarify `/seller/[id]` is the url you're navigating to from Search UI? NextJS router has difficulty with Search UI routing. Could you share an example of this working in codesandbox?

---

<div class="post-metadata">

**Author:** ![Lew\_Ashby](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lew_ashby/32/79866_2.png) [@Lew\_Ashby](https://discuss.elastic.co/u/Lew_Ashby)\
**Post date:** [January 5, 2023, 1:53am UTC](https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248/3 "2023-01-05T01:53:05Z")

</div>

Hi @joemcelroy, thanks for the reply

seller/[id] is a page were the user can navigate to get items from an specific seller, lets say. So, inside that page I use Search UI for filtering, etc, those items, when I activate a facet the url gets the parameters from the filters but rewrites the actual value of id with [id], ie. instead /seller/12/search\_ui\_filters the urls becomes /seller/[id]/search\_ui\_filters were search\_ui\_filters are all the filters activated

---

<div class="post-metadata">

**Author:** ![joemcelroy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joemcelroy/32/103757_2.png) [@joemcelroy](https://discuss.elastic.co/u/joemcelroy)\
**Post date:** [January 9, 2023, 1:13pm UTC](https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248/4 "2023-01-09T13:13:28Z")

</div>

thanks! Ive replicated the issue, working on finding a solution 🙂

---

<div class="post-metadata">

**Author:** ![joemcelroy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joemcelroy/32/103757_2.png) [@joemcelroy](https://discuss.elastic.co/u/joemcelroy)\
**Post date:** [January 9, 2023, 1:41pm UTC](https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248/5 "2023-01-09T13:41:55Z")

</div>

Right this is a working solution on codesandbox [priceless-dhawan-wpzewc - CodeSandbox](https://codesandbox.io/s/priceless-dhawan-wpzewc?file=/components/nextRouting.js)

The issue was we were updating the query params without the id in the query param. Nextjs uses the query params to interpolate the url. In the example above im retrieving the id and creating a new query object which contains both search ui params and next js router params.

Not too happy with the solution. Will update documentation if I figure a cleaner way, but this should unblock you.

---

<div class="post-metadata">

**Author:** ![Lew\_Ashby](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lew_ashby/32/79866_2.png) [@Lew\_Ashby](https://discuss.elastic.co/u/Lew_Ashby)\
**Post date:** [January 10, 2023, 12:54pm UTC](https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248/6 "2023-01-10T12:54:21Z")

</div>

thanks @joemcelroy for the solution and explanation, I appreciate the help.  
I hope the documentation get some update about this issue

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 7, 2023, 12:54pm UTC](https://discuss.elastic.co/t/integrating-search-ui-with-nextjs-router-dynamic-routes/322248/7 "2023-02-07T12:54:43Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
