algolia / algolia/instantsearch

Next.js - createURL function called outside of instant search context

Open
#5,507 7 comments 2 reactions 0 assignees View on GitHub
Library: InstantSearch.js
Dominant language
TypeScript
Stars
4.1k
Forks
553
Avg merge
1d 11h
Merged PRs (30d)
51

Description

### 🐛 Current behavior

I use the createURL options to personalize the URL of my search page with the new next.js router.

However, I see that this function is called even after I quit the search page and it generates troubles with the routing of the others pages.

### 🔍 Steps to reproduce

- Click on a item in the list
- get to the details page
- see that the createURL function has been called

### Live reproduction

https://codesandbox.io/p/sandbox/exciting-wright-yxmy7k?file=%2Fpages%2Findex.js&selection=%5B%7B%22endColumn%22%3A15%2C%22endLineNumber%22%3A35%2C%22startColumn%22%3A15%2C%22startLineNumber%22%3A35%7D%5D

### 💭 Expected behavior

createURl shouldn't be called outside of instant search context

### Package version

react-instantsearch-hooks 6.40.1

### Operating system

_No response_

### Browser

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start with the linked CodeSandbox reproduction and trace when the createURL option is invoked while navigating from the search results to a detail page. Confirm the behavior with the react-instantsearch-hooks 6.40.1 setup; done means createURL is not called after leaving the instant search context and other routes continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.