What is the easiest way to redirect to another page in an SPFX React app?

My App is fairly simple with only 2 pages each with a web part. I want to redirect from the home page to another page with a parameter that is used by the receiving page as a filter in a REST request.

I am trying to do it using location.href and putting the parameter in the query string, but I get an error 'The service worker navigation preload request was cancelled before 'preloadResponse' settled'

The service worker file 'spserviceworker.js' is coming from a cdn so I don't think it is possible to make changes to it to deal with the issue. I've tried adding another service worker file to the app without success.

I suppose I could look into using the React Router but it seems like a lot of trouble to go to for somthing that should be fairly simple.

  • Are you trying to open link in a new tab/window or within same tab? Nov 9, 2021 at 2:07
  • using the same tab Nov 9, 2021 at 2:35
  • Is there any reason you are not using simple HTML a tag hyperlink with target="_self"? Nov 9, 2021 at 6:09
  • I'm doing the redirect on a button click. I need to get a value to add to the query string before doing the redirect Nov 9, 2021 at 21:22

1 Answer 1


I've moved the functionality in the 2 web parts into one web part so I don't need to navigate to another page, I just hide and show elements on the page as required. It seems SPFX is not keen on passing a parameter in a query string to another page to be consumed in web part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.